script to SSH to host
:cool:
Code:
def main(): I am trying to string a ssh command but getting an error. I just want it to run the command and loop through. Any ideas? |
Quote:
What is the exact text of the error you're seeing? I can share things I see wrong with your code, but without any details about the error you're seeing, it's possible that none of them will have anything to do with the error you're seeing. Here are my in-the-dark-because-you-haven't-said-what-the-error-is observations:
|
Sorry to dig up an old thread but something is wrong with the code.
Code:
# $language = "python" when it runs Code:
# ssh -oStrictHostKeyChecking=no root@myhost it should be all one line # ssh -oStrictHostKeyChecking=no root@myhost "ps -ef | grep gofer" |
Quote:
If using this host variable to compose your command (which doesn't have any literal \r or \n in the string between the hostname and the rexec portion of the command) results in output as you describe with the rexec portion appearing on a separate line, then it must mean that your host variable has some embedded \r and/or \n character(s) that cause the entire command to be sent to the remote as two separate lines. Consider using the Python-provided strip() method on your host variable to remove any unwanted \r or \n characters, as demonstrated in this example demonstrating a before and after. Then use the same pattern to fix your code. Code:
# $language = "python" Code:
# $language = "python" |
All times are GMT -6. The time now is 01:13 PM. |