Question

I am using python 2.7.6 for scripting

problem statement:- In my script, I have extracted my applicationId in variable say 'appid' at runtime now I have to pass this as variable in SSHClient command to be executed in remote server, in cmd below

ssh_idb = SSHClient(cfg_cluster_ip)
ssh_idb.login_with_password(username=idb_ssh_user,password=idb_ssh_password)
cmd ='ps -ef | grep "Admin|$appid"'
out, err, code = ssh_idb.execute_sudo_command(["%s" % cmd])
print out

It returns blank output [expected value is not being passed in cmd and shell doesn't returns any data] Is there a way to pass local variable value in cmd dynamically ?

Was it helpful?

Solution

This question is very unclear. Do you mean appid is a local variable in your Python script? If so, you need to pass it to the command string:

cmd ='ps -ef | grep "Admin|%s"' % appid
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top