LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-05-2012, 02:46 AM   #1
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657

Rep: Reputation: 40
SSH remote command: Pipe remote output to local machine?


Hi all,

I'm running a command such as this:

Code:
ssh user@remote.example.com "python script.py"
When the script finishes, it's output is returned to my local server. What I would like to get working is having the script output continiously directed to my local server, so that I don't have to wait for the script to finish to get the output.

Is there a way to get this working?


Best regards,
kenneho
 
Old 12-05-2012, 03:35 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
All the output generated by a script is shown locally the moment the script prints/echo's it.

You need to alter your python script.
 
1 members found this post helpful.
Old 12-06-2012, 01:13 AM   #3
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by druuna View Post
All the output generated by a script is shown locally the moment the script prints/echo's it.

You need to alter your python script.
Thanks, I think you're right. I tried this command:
Code:
ssh user@remote.example.com "date; sleep 5; date"
which output data at the moment the commands echo it. But with the python script, it seems to delay the output until the script has completed. In my script I have plain "print" statements, so I'm puzzled as to what may be causing the delay. Anyone got any ideas?
 
Old 12-06-2012, 01:19 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by kenneho View Post
But with the python script, it seems to delay the output until the script has completed. In my script I have plain "print" statements, so I'm puzzled as to what may be causing the delay. Anyone got any ideas?
You do need to know that I never programmed in python, but if it is anything like perl then it could be an output buffering issue.

A quick search comes up with this: Python output buffering
 
1 members found this post helpful.
Old 12-06-2012, 01:32 AM   #5
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by druuna View Post
You do need to know that I never programmed in python, but if it is anything like perl then it could be an output buffering issue.

A quick search comes up with this: Python output buffering
Excellent, it was indeed a python buffering issue. When using "python -u script.py" it now output the info immediately.
Thank you for your help.
 
Old 12-06-2012, 01:35 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405


Can you put up the [SOLVED] tag.
- above the first post -> Please Mark this thread as solved if you feel a solution has been provided.
- -or- -
- first post -> Thread Tools -> Mark this thread as solved
 
Old 12-06-2012, 01:37 AM   #7
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by druuna View Post


Can you put up the [SOLVED] tag.
- above the first post -> Please Mark this thread as solved if you feel a solution has been provided.
- -or- -
- first post -> Thread Tools -> Mark this thread as solved
Done.
 
  


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
Can't SSH to remote machine: Connection closed by remote host Avatar Linux - Networking 35 10-23-2017 12:21 AM
[SOLVED] How can I ssh/scp into a remote's machine local machine? venom4u31 Linux - Newbie 6 11-05-2011 01:36 PM
SSH remote command withouth output Ricio Linux - Newbie 5 10-20-2008 11:44 AM
how to open a dilog on local machine when i do ssh to remote machine fahad26 Programming 3 05-03-2005 07:39 PM
How do I setup xwindow to run a remote desktop on my local machine through ssh. green-ears Linux - Newbie 4 11-04-2003 05:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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