LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-06-2011, 09:11 AM   #1
shwethavb
LQ Newbie
 
Registered: May 2011
Posts: 18

Rep: Reputation: Disabled
In Redat linux, Regarding output redirection of command


Am using Rehat linux, when i use command "PING IP-ADDRESS",

My requirement is

output of ping command should get saved to some text file automatically along with time and date of ping,

How can i do that??

Anyone Please suggest me ASAP.

Thanks in advance
 
Old 07-06-2011, 10:37 AM   #2
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
[code]ping -c 1 127.0.0.1>ping.txt[code]
or if you want something that looks a bit more like a log (with the times of execution
Code:
(date;ping -c 1 127.0.0.1)>>ping.txt
 
Old 07-06-2011, 10:57 AM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Code:
while true; \
do d=$(date); \
p=$(ping -c 1 8.8.8.8 | grep received); \
echo "$d: $p" >> output.txt 2>&1; sleep 1; \
done;
 
Old 07-06-2011, 12:18 PM   #4
shwethavb
LQ Newbie
 
Registered: May 2011
Posts: 18

Original Poster
Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by 16pide View Post
[code]ping -c 1 127.0.0.1>ping.txt[code]
or if you want something that looks a bit more like a log (with the times of execution
Code:
(date;ping -c 1 127.0.0.1)>>ping.txt

Its working well and fine||| thanks a lot
 
  


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
Output Redirection - Trying to output to screen and file? helptonewbie Linux - Newbie 7 03-19-2009 07:05 AM
LXer: Simple Multiple-Steam Output Redirection With Zsh On Linux and Unix LXer Syndicated Linux News 0 07-23-2008 07:41 AM
command output redirection radiodee1 Linux - Newbie 1 01-02-2008 11:24 AM
tar command output redirection ah_kayyali Linux - Newbie 4 03-19-2006 06:30 AM
LXer: Input / Output Redirection made simple in Linux LXer Syndicated Linux News 0 01-06-2006 10:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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