0

I'm trying to run a timeout command, with root password and strace all in one line, the original cmmand is

sudo -S timeout 4 strace -p 2829 -f -e trace=write -s 9999

but that promps for entering the root password. which I already have and wants to put it in one line, so this becomes

echo ROOT_PASSWORD | sudo -S strace -p 2829 -f -e trace=write -s 9999

I tried putting timeout in the front, middle or at the end but it doesn't work, such as

timeout 4 | echo ROOT_PASSWORD | sudo -S strace -p 2829 -f -e trace=write -s 9999

thank you for your help! =)

  • Why not just configure sudo to allow password less execution? – Raman Sailopal Jan 5 '18 at 11:22
0

Create a shell script that outputs the password, and save it somewhere such as /home/user/getpass.sh. Then run this:

SUDO_ASKPASS=/home/user/getpass.sh sudo -A timeout 4 strace -p 2829 -f -e trace=write -s 9999

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.