Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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@192.168.1.1:/mnt/capture/logs/

The command used to run the script

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

The script.sh file is as follows

#!/bin/bash
sudo /mnt/md0/capture/logs/install.sh

The plink command gives script.sh : Permission denied.

share|improve this question
    
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

1 Answer 1

up vote 3 down vote accepted

call the chmod before you invoke it:

plink -ssh -pw password -noagent user@192.168.1.1 "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?

share|improve this answer
    
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

 
discard

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.