Basiclly I'm trying to run sh script on linux server by running python script on my local machine but I have no idea how to pass the 1 or 0. I checked if it runs sh properly when it just has to create folder without any passing and it worked - also with sh script but I only needed to run it. SH
echo "Enter 1 to create a folder named 'Hello'"
echo "Enter 0 to exit"
read choice
if [ $choice -eq 1 ]
then
mkdir Hello
echo "Folder 'Hello' created!"
elif [ $choice -eq 0 ]
then
exit
else
echo "Invalid choice"
fi
I also checked above script by running it manual and it also worked fine. And the python function I'm trying to use:
from multiprocessing import Pool
import paramiko
import shlex
def log_to_machine(machines):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(machines, username = 'pluszczu', password = 'pluszczu1')
script_run(ssh)
ssh.close()
def mp(machines):
p = Pool()
result =p.map(log_to_machine, machines)
p.close()
p.join()
def script_run(ssh):
path = '/home/pluszczu/logs'
ssh.exec_command(f'cd {shlex.quote(path)} && ./zac.sh 1')
if __name__ == '__main__':
machines = [
r'192.168.56.102',
]
mp(machines)
Rest of the code is fine. I also tried like && echo 1, $1, echo $1 but with the same resut. Any ideas how can I pass that value?