LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   I am trying to remote execute a python command vis ssh. I am getting a syntax error from the remote server. (https://www.linuxquestions.org/questions/linux-networking-3/i-am-trying-to-remote-execute-a-python-command-vis-ssh-i-am-getting-a-syntax-error-from-the-remote-server-4175562530/)

buckb 12-28-2015 03:44 PM

I am trying to remote execute a python command vis ssh. I am getting a syntax error from the remote server.
 
[root@fuel ~]# echo "glance-control all status" | ssh root@10.11.32.16 /usr/bin/python
Warning: Permanently added '10.11.32.16' (RSA) to the list of known hosts.
File "<stdin>", line 1
glance-control all status
^
SyntaxError: invalid syntax[/SIZE][/FONT]
[root@fuel ~]#

I have done many searches, and have tried altering syntax. I always get the same error.

Any help would be appreciated.

suicidaleggroll 12-28-2015 04:01 PM

What is the output if you ssh into the computer first, and then run:
Code:

echo "glance-control all status" | /usr/bin/python

michaelk 12-28-2015 05:38 PM

The correct syntax to run a remote command via ssh is:

ssh root@10.11.32.16 '/usr/bin/python glance-control all status'

suicidaleggroll 12-28-2015 05:46 PM

Quote:

Originally Posted by michaelk (Post 5470090)
The correct syntax to run a remote command via ssh is:

ssh root@10.11.32.16 '/usr/bin/python glance-control all status'

You need "-c" to do that, otherwise python tries to execute the file "glance-control", which would fail

Code:

ssh root@10.11.32.16 '/usr/bin/python -c "glance-control all status"'

michaelk 12-28-2015 05:59 PM

True and we probably need more information. From a quick google, glance is a HP-UX monitoring tool similar to nagios and glance-control is the command line access tool. So I believe the op is trying to run a remote command.

buckb 12-29-2015 06:40 AM

Quote:

Originally Posted by suicidaleggroll (Post 5470065)
What is the output if you ssh into the computer first, and then run:
Code:

echo "glance-control all status" | /usr/bin/python

Same error

root@node-29:~# echo "glance-control all status" | /usr/bin/python
File "<stdin>", line 1
glance-control all status
^
SyntaxError: invalid syntax

buckb 12-29-2015 06:42 AM

Quote:

Originally Posted by suicidaleggroll (Post 5470092)
You need "-c" to do that, otherwise python tries to execute the file "glance-control", which would fail

Code:

ssh root@10.11.32.16 '/usr/bin/python -c "glance-control all status"'

Almost the Same Error

# ssh root@10.11.32.16 '/usr/bin/python -c "glance-control all status"'
Warning: Permanently added '10.11.32.16' (RSA) to the list of known hosts.
File "<string>", line 1
glance-control all status
^
SyntaxError: invalid syntax

buckb 12-29-2015 07:52 AM

michaelk is correct, in that more information is needed.

1) glance is a piece of openstack.
2) glance-control is a tool to handle bringing up and down the glance daemons. By itself, glance-control works.
e.g.
root@node-29:~# glance-control all status
glance-api is stopped
glance-registry is stopped
glance-scrubber is stopped


The problem is trying to get glance-control to work via ssh.

Here is the original error, which I did not post

Quote:

# ssh root@10.11.32.16 'glance-control all status'
Warning: Permanently added '10.11.32.16' (RSA) to the list of known hosts.
Traceback (most recent call last):
File "/usr/bin/glance-control", line 10, in <module>
sys.exit(main())
File "/usr/lib/python2.7/dist-packages/glance/cmd/control.py", line 362, in main
do_check_status(pid_file, server)
File "/usr/lib/python2.7/dist-packages/glance/cmd/control.py", line 209, in do_check_status
print(_("s is stopped") server)
File "/usr/lib/python2.7/dist-packages/oslo_i18n/_message.py", line 167, in __str__
raise UnicodeError(msg)
UnicodeError
After doing web searches, I tried what is in my original post, as well of variations of the same.

I believe this is a SSH syntax error.


Well, while writing this reply, I solved this problem. I went through the ssh man page again and added the -t option to the ssh command.

Quote:

# ssh -t root@10.11.32.16 'glance-control all status'
Warning: Permanently added '10.11.32.16' (RSA) to the list of known hosts.
glance-api is stopped
glance-registry is stopped
glance-scrubber is stopped
Connection to 10.11.32.16 closed.

Thanks for all who replied.


All times are GMT -5. The time now is 09:33 AM.