How do I pass a Python variable to Bash Shell over SSH connection? -


this question has answer here:

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

Popular posts from this blog

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -