LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-13-2007, 04:03 PM   #1
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Rep: Reputation: 39
Question Output contents to file on server from konsole


what i'd like to do is put the output from a command that continuously loops into a file on the same server i ssh into. for example i'm on server1 and ssh to server2

now if i do this,
ssh user@server2 echo "Hello" > /file.txt

then the file.txt is saved to server one and i want the output to stay on server2, and no, copying it over isn't an option as i'm really trying to get it to work with the nohup command.

As when the connection to the /dev/null is lost the process stops working as well, thats why i want the output to be going to the same server (server2) that i'm trying to get this command to run on.

not sure how to do it i did something like //servername/target but that didn't work at all

Anyideas, maybe just how to get the echo to output to the server2 when running the command on server2 would be a start


thanks
 
Old 02-13-2007, 04:37 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

Code:
ssh user@server2 'echo "Hello" > /file.txt'
should do the job.

Dave
 
Old 02-13-2007, 04:40 PM   #3
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
thanks but nope i've tried that already
although i used ` and not '
i thought ' was primarily to show text strings rather like ", i'll give it a whirl
thanks and i'll write back
 
Old 02-13-2007, 04:54 PM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi again.

Quoting in the shell can get a bit weird. Basically:

"" = treat the quoted contents as one object, and allow shell expansion ($HOME becomes /home/username, for example)
'' = treat the quoted contents as one object, with no shell expansion ($HOME would be passed as a literal $HOME string)
`` = run the quoted contents as a shell command, and replace the quote with the output from that command

(Sorry if that was a bit patronising, but maybe it'll be of use to googlers later).

Dave
 
Old 02-13-2007, 05:00 PM   #5
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
Talking

sorry didn't see you second post due to testing out what you had put, i just want to say i could kiss you right now

Yes that worked great, its sorted out a problem i was having with the nohup command. i was ssh-ing into another server and trying to run a process with the nohup which should say running constantly, but when i closed the ssh it closed the session and because the other server was obviously trying to get to this servers /dev/null and couldn't therefore it closed the process. But i didn't know how to make output targets when using them remotley output to that same server and not the one i was using to ssh with, your echo stuff showed me it was possible i did the same with my nohup command and it worked fantastic.

Thankyou very much totally bang on brilliance.
 
  


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
Bash remove part of a file based on contents of another file bhepdogg Programming 4 01-31-2007 03:13 PM
Input/output error after mounting floppy and trying to access contents on GNU/Linux OliverThomas Linux - Hardware 1 01-04-2007 04:23 AM
Text output 'scrambled' in Konsole, ok in other apps tisource Linux - Software 0 08-28-2006 01:18 AM
How do I open a konsole window, and send output to it? Robhogg Programming 4 05-01-2006 09:17 AM
Backing up the contents of a file server to DVD? CatchFlipsidE Linux - Newbie 2 09-23-2004 07:36 PM

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

All times are GMT -5. The time now is 12:51 PM.

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