Execute Command/script Using Different Shell In SSH/Paramiko
Solution 1:
Your question has nothing to do with Paramiko. Try to paste your command in SSH terminal - It won't work either.
The syntax aaa ; bbb
executes the commands one after another. bbb
won't be executed until aaa
finishes. Similarly, /bin/bash ; echo $shell
executes bash
and the echo
won't be executed until bash
finishes, what it never does, hence the hang.
You actually do not want to execute echo
after bash
- you want to execute echo
within bash
.
If you want to execute a script/commands within a different shell, you have three options:
Specify the shell that the script needs in the script itself using shebang - This the the right way for scripts.
#!/bin/bash
Execute the script/commands using shell command-line:
/bin/bash script.sh
or
/bin/bash -c "command1 ; command2 ; ..."
Write the script/command to be executed to a shell input, like I've shown you in your previous question:
Pass input/variables to bash script over SSH using Python Paramiko
Post a Comment for "Execute Command/script Using Different Shell In SSH/Paramiko"