The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Full Command Logging? humbletech99 Security 1 01-29-2009 11:08 AM
shell command logging minkie SUN Solaris 2 12-04-2008 02:37 PM
Command Logging in SCO brian_g UNIX for Dummies Questions & Answers 2 04-13-2006 06:46 PM
What is command for logging? dtamminx UNIX for Dummies Questions & Answers 3 02-11-2003 06:58 PM
SSH and command logging penguin-friend UNIX for Advanced & Expert Users 2 02-25-2002 06:11 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-01-2009
pravfraz pravfraz is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 5
awk command-logging

hi folks,

In the following code, logfile remains empty.
Code:
 
log_file="/u/Sc/prav.log.$mon$day"
 
ps -ef | grep "myprocess"| awk -v logfile=$log_file '{
 system("date >> logfile")
}'
can u please help as how to log the date to that logfile.
thanks in advance!
  #2 (permalink)  
Old 07-01-2009
rakeshawasthi rakeshawasthi is offline
Registered User
  
 

Join Date: Aug 2004
Location: India
Posts: 379
For me your code generates a file with the name "logfile" in the current directory and prints the date there.
Are you initialising the variables "mon" and "day" somewhere?
  #3 (permalink)  
Old 07-01-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Quote:
Originally Posted by pravfraz View Post
hi folks,

In the following code, logfile remains empty.
Code:
 
log_file="/u/Sc/prav.log.$mon$day"
 
ps -ef | grep "myprocess"| awk -v logfile=$log_file '{
 system("date >> logfile")
}'
can u please help as how to log the date to that logfile.
thanks in advance!
  1. why do you need awk? Cannot you use file redirection instead?
  2. If you do need awk, why do you need 'grep'? Awk can do it all.
  3. ps -ef | awk -v logfile="${log_file}" '/myprocess/{cmd="date >> " logfile; system(cmd); close(cmd)}"
  #4 (permalink)  
Old 07-02-2009
pravfraz pravfraz is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 5
thanks a lot!!
i resolved it with your help!
forum rocks!!
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0