I am trying to use pexpect and pxssh to automate some tasks. I am not very familiar with python. I would like to run a shellscript with some arguments on a server. But the shellscript is hosted locally.
I am now trying to do it like this:
s = pxssh.pxssh()
s.login(host, user, pass)
f = open("./connect.sh", "r")
for line in f:
s.sendline(line)
s.prompt()
print s.before
connect.sh
has an awk one liner. So it reads one line, and sends it directly to the server via pxssh. This works.
However, I want to pass arguments to the shellscript. The awk one liner has a $1 and $2 in it, so they need to be replaced. I think I could manually replace $1 with the first argument, and $2 with the second, so I form a new awk command, and then send the new command to the server with pxssh. But I think there is a smarter way of doing that. So what is the correct way to do this?