LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-28-2015, 03:44 PM   #1
buckb
LQ Newbie
 
Registered: Mar 2013
Posts: 6

Rep: Reputation: Disabled
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.
 
Old 12-28-2015, 04:01 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
What is the output if you ssh into the computer first, and then run:
Code:
echo "glance-control all status" | /usr/bin/python
 
Old 12-28-2015, 05:38 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

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

ssh root@10.11.32.16 '/usr/bin/python glance-control all status'
 
Old 12-28-2015, 05:46 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by michaelk View Post
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"'

Last edited by suicidaleggroll; 12-28-2015 at 05:49 PM.
 
Old 12-28-2015, 05:59 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
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.
 
Old 12-29-2015, 06:40 AM   #6
buckb
LQ Newbie
 
Registered: Mar 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by suicidaleggroll View Post
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
 
Old 12-29-2015, 06:42 AM   #7
buckb
LQ Newbie
 
Registered: Mar 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by suicidaleggroll View Post
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

Last edited by buckb; 12-29-2015 at 06:53 AM. Reason: Changed 'Same Error' to 'Almost the Same Error'
 
Old 12-29-2015, 07:52 AM   #8
buckb
LQ Newbie
 
Registered: Mar 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
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.

Last edited by buckb; 12-29-2015 at 07:59 AM. Reason: Corrected punctuation.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH execute remote command as local! elalexluna83 Linux - Server 8 06-05-2015 07:59 PM
ssh to a remote machine, execute a command | from Cron wh33t Linux - Newbie 2 09-03-2014 05:06 PM
[SOLVED] SSH remote command: Pipe remote output to local machine? kenneho Linux - Server 6 12-06-2012 01:37 AM
SSH: How to run console/command in remote server's memory? Vince-0 Linux - Server 3 03-09-2008 10:36 AM
SSH Error to remote Server shawnbishop Linux - Software 1 06-04-2007 01:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration