How do I pass a Python variable to Bash Shell over SSH connection? -
this question has answer here:
- python string formatting: % vs. .format 11 answers
i try check file existence on remote server. works fine me, except want pass file path variable.
here _,stdout,_=ssh.exec_command("[ -f d:/tryssh/1.txt ] && echo ok")
and need d:/tryssh/1.txt variable specify in python script used later in bash, this
`_,stdout,_=ssh.exec_command("[ -f $filepath ] && echo ok")`
as command string, use string:
file_path = "d:/tryssh/1.txt" command = "[ -f %s ] && echo ok" % file_path _,stdout,_=ssh.exec_command(command)
Comments
Post a Comment