0

This is my command.sh[After entering the command nothing happened][2]I want to automate the commands in putty so i have written the commands in a shell script and called it from a batch file

echo -e "password" | sudo -S screen -ls  
pwd 
cd .. 

these are the commands in shell script, but the commands pwd, cd are not executing after sudo commands..... No commands are working under sudo commands

2
  • 1
    How do you execute your script? You wrote batch file, which means a script file windows cmd, was this just a typo? Do the exact same commands work when entered directly in bash? Commented Mar 7, 2019 at 12:44
  • putty.exe -ssh user@hostname -pw password -m myshell.sh -t this is the command in batch file . Commented Mar 7, 2019 at 12:51

1 Answer 1

1

That happens because you launch screen and the process never exits so the bash script cannot move forward to the pwd and cd commands

As a workaround you may write down your commands into the shell script and execute it in screen using

screen -d -m bash ./script.sh
Sign up to request clarification or add additional context in comments.

2 Comments

I have tried this comment but nothing happened , I have attached the screen shot
what do you expect from the "screen" program? Why do you use it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.