I am writing my first ever bash script, so excuse the noobie-ness.
It's called hello.bash, and this is what it contains:
#!/bin/bash
echo Hello World
I did
chmod 700 hello.bash
to give myself permissions to execute.
Now, when I type
exec hello.bash
My putty terminal instantly shuts down. What am I doing wrong?
To ensure that the ssh session windows does not close and to view the error message on the server side, set 'Close Window on exit' to 'Never' under the Session tab as shown below. This is useful in troubleshooting ssh failure during ssh access to the remote ssh gateway.
“run sh file in putty” Code Answer ./script-name-here.sh #Chage the "script-name-here" to the name of the . sh file.
From the man page for exec:
If command is supplied, it replaces the shell without creating a new process. If no command is specified, redirections may be used to affect the current shell environment.
So your script process runs in place of your terminal and when it exits, so does your terminal. Just execute it instead:
./hello.bash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With