LinuxQuestions.org
Visit Jeremy's Blog.
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, 04: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, 05:01 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138
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, 06:38 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 22,054

Rep: Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425
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, 06:46 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138Reputation: 2138
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 06:49 PM.
 
Old 12-28-2015, 06:59 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 22,054

Rep: Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425
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, 07: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, 07: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 07:53 AM. Reason: Changed 'Same Error' to 'Almost the Same Error'
 
Old 12-29-2015, 08: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 08:59 AM. Reason: Corrected punctuation.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 08:59 PM
ssh to a remote machine, execute a command | from Cron wh33t Linux - Newbie 2 09-03-2014 06:06 PM
[SOLVED] SSH remote command: Pipe remote output to local machine? kenneho Linux - Server 6 12-06-2012 02:37 AM
SSH: How to run console/command in remote server's memory? Vince-0 Linux - Server 3 03-09-2008 11:36 AM
SSH Error to remote Server shawnbishop Linux - Software 1 06-04-2007 02:50 AM

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

All times are GMT -5. The time now is 02:43 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