![]() |
unable to run unix command using spur - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: unable to run unix command using spur (/thread-12630.html) Pages:
1
2
|
unable to run unix command using spur - purnima1 - Sep-04-2018 Hi Experts , I am trying to run simple command but getting an error import spur import spur.ssh try: shell = spur.SshShell(hostname="EDQDVTAPP01.XXXXXX.com",port=22,username="applogs",password="XXXXXX",missing_host_key=spur.ssh.MissingHostKey.accept) with shell: result = shell.run("ls") print (result) except spur.ssh.ConnectionError as error: print (error.original_traceback) raise
RE: unable to run unix command using spur - buran - Sep-04-2018 try import spur import spur.ssh try: shell = spur.SshShell(hostname="EDQDVTAPP01.XXXXXX.com",port=22,username="applogs",password="XXXXXX",missing_host_key=spur.ssh.MissingHostKey.accept) with shell: result = shell.run(["ls"]) print (result) except spur.ssh.ConnectionError as error: print (error.original_traceback) raise RE: unable to run unix command using spur - purnima1 - Sep-05-2018 Hi Barun, I think you have included [] around command. I tried that also but getting same error RE: unable to run unix command using spur - buran - Sep-05-2018 Yes, that is what I did. Are you sure it's the same error? Please, post the full traceback According to docs, shell.run should get a list of strings. Also obviously from your error it starts to iterate over the argument that has been passed to run() - in your case it try to execute just l as command...
RE: unable to run unix command using spur - purnima1 - Sep-05-2018 Hi expert, As you said I have changed my code as follows but still getting error. How can I ensure before running any command I am hit that server .Till now I am trying to do this by running ls command import spur import spur.ssh try: shell = spur.SshShell(hostname="EDQDVTAPP01.XXXXX.com",port=22,username="applogs",password="XXXXX",missing_host_key=spur.ssh.MissingHostKey.accept) with shell: result = shell.run(["l"]) print (result) except spur.ssh.ConnectionError as error: print (error.original_traceback) raise
RE: unable to run unix command using spur - buran - Sep-05-2018 note that your line#7 is incorrect. The command you try to run is "l", not "ls" RE: unable to run unix command using spur - purnima1 - Sep-05-2018 hi In my post I have mentioned l only . I am not using ls . Still it is giving same error with l RE: unable to run unix command using spur - buran - Sep-05-2018 There is no command "l". How do you expect to run non-existing command? You claim you want to run "ls": (Sep-05-2018, 06:32 AM)purnima1 Wrote: Till now I am trying to do this by running ls command line# 7 should be result = shell.run(["ls"]) RE: unable to run unix command using spur - purnima1 - Sep-05-2018 hi All, I am getting same error. import spur import spur.ssh try: shell = spur.SshShell(hostname="EDQDVTAPP01.XXXXX.com",port=22,username="applogs",password="XXXXX",missing_host_key=spur.ssh.MissingHostKey.accept) with shell: result = shell.run(["ls"]) print (result) except spur.ssh.ConnectionError as error: print (error.original_traceback) raise
RE: unable to run unix command using spur - buran - Sep-05-2018 the obly thing that comes to my mind is try to replace line#7 with shell.run(["sh", "-c", "echo $PATH"])and see if everything is OK with $PATH |