LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 03-25-2011, 08:10 AM   #1
Zmegolaz
LQ Newbie
 
Registered: Mar 2011
Location: Sweden
Distribution: Gentoo, Red Hat, Debian, Ubuntu
Posts: 7

Rep: Reputation: 0
Pipe in autocommand in gnome-terminal


Hi,

I'm having some problems with the auto execution option in gnome-terminal.

What I'm trying to do is this to start a new terminal, and run "ssh [ip] | tee -ai [log file]" automatically. I've tried two ways to accomplish this, nr 1:
Code:
gnome-terminal -e "ssh 10.80.250.239 | tee -ai ~/sshlogs/log-`date +%Y-%m-%d-%H%M%S`.log"
and nr 2:
Code:
gnome-terminal -x ssh 10.80.250.239 | tee -ai ~/sshlogs/log-`date +%Y-%m-%d-%H%M%S`.log
None of them works. In the first example ssh treats the | and everything after it as a command to execute on the remote server I'm SSHing to, it's like the | is escaped in some way.

In the second example everything seems to work, except that the log file is empty. I think that the output of the gnome-terminal is piped to tee, and the | is not passed to the new terminal window at all.

So my question is, how do get the | to be sent to the new terminal, and to be treated as a | there?

Thanks,
Zmegolaz
 
Old 03-27-2011, 06:33 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
What are you trying to achieve with 'ssh [ip] | tee -ai [log file]' ?
 
Old 03-28-2011, 01:11 AM   #3
Zmegolaz
LQ Newbie
 
Registered: Mar 2011
Location: Sweden
Distribution: Gentoo, Red Hat, Debian, Ubuntu
Posts: 7

Original Poster
Rep: Reputation: 0
I'm trying to log all SSH output to a file. I used to do this when I was using PuTTY and find it very useful to be able to go back and check what I did and what output I got from commands earlier.

/ Zmegolaz
 
Old 03-28-2011, 07:05 AM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Try it like this :-

Code:
gnome-terminal -x sh -c "ssh <ip_address> | tee -ai <log_file>"
.. worked for me

cheers
 
1 members found this post helpful.
Old 03-28-2011, 08:46 AM   #5
Zmegolaz
LQ Newbie
 
Registered: Mar 2011
Location: Sweden
Distribution: Gentoo, Red Hat, Debian, Ubuntu
Posts: 7

Original Poster
Rep: Reputation: 0
Works like a charm, thank you very much!

/ Zmeg
 
  


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
LXer: Determine If Shell Input is Coming From the Terminal or From a Pipe LXer Syndicated Linux News 0 02-11-2010 06:30 AM
Autocommand like in vi for kate or quanta loonyxp Linux - Desktop 0 11-27-2006 02:40 PM
rsh & invalid autocommand JJX Linux - Networking 0 03-13-2006 09:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

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