I have a set of bash scripts I want to install to a remote linux system. I have created a batch file to be run on the windows host system using plink and putty to transfer the files to the linux system. But Plink is not able to run the install script, which actually schedules the scripts in to crontab it gives "Permission denied error" as chmod command is not run. Is there any work around this? The command used to send files to the linux box

 "c:\Program Files (x86)\PuTTY\pscp" -pw passwd *.sh   user@

The command used to run the script

"c:\Program Files (x86)\PuTTY\plink.exe" -ssh -pw passwd -noagent user@   /mnt/capture/logs/script.sh

The script.sh file is as follows

sudo /mnt/md0/capture/logs/install.sh

The plink command gives script.sh : Permission denied.

  • Could you clarify your question? For example, what exactly are you running? Can you post the commands, or an example of them? What fails? How do I reproduce the error? – lorenzog Feb 26 '14 at 12:37

call the chmod before you invoke it:

plink -ssh -pw password -noagent user@ "sh -c 'cd /mnt/capture/logs && chmod a+x *.sh && ./script.sh'"

If you have edited the script in a Windows text editor, make sure they are saved in Unix file format so that you do not have CR-NL line endings.

Also, your script uses sudo -- is user nethawk listed in the sudoers file? Are you expected to enter your password?

  • I want the user to enter the sudo password. – Jishnu U Nair Feb 26 '14 at 14:32
  • You'll probably need to use something like expect to build in that level of interactivity. You won't get it with ssh user@host command – glenn jackman Feb 26 '14 at 14:56
  • the bat file gives me error "sudo: no tty present and no askpass program specified" – Jishnu U Nair Feb 26 '14 at 14:56
  • That's a clue: hunt around for a windows-and-plink-compatable askpass program – glenn jackman Feb 26 '14 at 14:57
  • 2
    Got it -ssh -t asked for the sudo password.. and all done :) cheers mate .. thanks for help – Jishnu U Nair Feb 26 '14 at 15:00

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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