Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I have written one bash script and it is run on the background, inside this script I have use the following command:

sshpass -p prakash123 ssh -t -p $1 prakash@localhost './update_script.sh > /update.out 2> /update.err < /dev/null | echo $! > /update.pid &'

It is working fine. But I want to change the location of /update.out ,/update.err and /update.pid So modified command for that:

sshpass -p prakash123 ssh -t -p $1 prakash@localhost './update_script.sh > /pra/log/update.out 2> /pra/log/update.err < /dev/null | echo $! > /pra/log/update.pid &'

Now I am getting the permission denied error.

Because I changed the path of output files. I am not sure but I think I have to give the super user permission like su or sudo before the sshpass

So how can I change the path of /update.out , /update.err and /update.pid this file from the above command.?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

In the first command, you are writing the output to a location that you have write access to, so everything is fine there.

Now the /pra directory does not exist by default, so I assume you have created it using root access. So to write to it, you have to use root access as well. Just add sudo to the command as,

sudo sshpass -p prakash123 ssh -t -p $1 prakash@localhost './update_script.sh > /pra/log/update.out 2> /pra/log/update.err < /dev/null | echo $! > /pra/log/update.pid &'

But rather than doing this ,I would suggest you write to a directory in $HOME dir and give it rwx------ permission(i.e read/write/execute for you and no permissions to others).Thus you won't have to use sudo.

share|improve this answer
/pra/log/ directory is exist by default. I think sudo is best option for me because I am not able to change the directory permission /pra/log because other user also have access of this directory. I tried your command but ./update_script.sh file not executed. In your above command what is "entersshpass" you mean this is superuser pass or anything else. –  Prakash V Holkar Apr 8 '14 at 10:06
@prakash there are some unwanted guests in the command. Just add sudo before your command. I will edit the answer later when using my computer. –  Registered User Apr 8 '14 at 10:16
sure, I have added sudo before my command but it is not working for me. I am not getting /update.out , /update.err and /update.pid files inside the /pra/log directory. –  Prakash V Holkar Apr 8 '14 at 10:27
@PrakashVHolkar post the error. –  Registered User Apr 8 '14 at 10:28
I am getting following error: Host key verification failed. –  Prakash V Holkar Apr 8 '14 at 10:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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