The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Jumpstart Issues Solaris 10 soupbone38 SUN Solaris 7 12-08-2008 05:41 AM
Script works on Solaris, not on Linux Silverhood Shell Programming and Scripting 1 10-05-2007 09:52 AM
Script works on Solaris, not on Linux Silverhood Shell Programming and Scripting 0 10-05-2007 09:27 AM
Samba 3.0.14 on Solaris 10 issues Sapna SUN Solaris 0 10-10-2005 02:21 PM
Solaris boot issues xyyz UNIX for Advanced & Expert Users 6 02-14-2003 02:36 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-22-2009
LRoberts LRoberts is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 87
Solaris / Linux Issues with script

Hello,

I run this command from a solaris box and it works just fine. It gives me the kind of output in my file I am looking for which would be for example...

sb1p
rdop
ot2p
ot3p
eimp


However when I do the same thing from a Linux box...

ps -ef | grep nco_p_syslog | grep -v grep | awk '{print $NF}' | awk -F. '{print $1}' > $OMNIHOME/bin/syslogfile.dat


I get this in the file...
/lcl/apps/Tivoli/netcool/omnibus/probes/linux2x86/syslog


Both are using
#!/bin/ksh


I have no idea where it is even getting that long directory path from for the results.

Any ideas?

Thanks in advance.
  #2 (permalink)  
Old 04-22-2009
kodak kodak is offline
Registered User
  
 

Join Date: Jun 2003
Posts: 51
It's differences between the output of solaris ps and linux ps. You'll probably have to make modifications with allowances for the different OSes. You could probably do some case switching magic to do it all in one script, though.

Anyway, I don't have access to a solaris box at the moment, so my suggestion is to start with the base command and work down from there, adding on the pipes one at a time until you figure out where the difference is.

Do:

ps -ef | grep nco_p_syslog

on both, then compare the output. If you don't understand what each command does, you should spend some time reading the various manual pages until you do.
  #3 (permalink)  
Old 04-22-2009
LRoberts LRoberts is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 87
Ok I have been trying that and did some reading up on awk however I can not seem to find how to only capture the last part.

Currently I do...
Code:
ps -ef | grep nco_p_syslog | grep -v grep | awk '{print $NF}' | awk -F. '{print $1}' > $OMNIHOME/bin/syslogfile.dat
Which gives the results of....
Code:
/lcl/prd/data/dc000p/dump/bdump/alert_dc000p
I only want the dc000p part to record to the dat file.
For the life of me I can not seem to figure out the awk commands to do that.

Any help would be great also explaining how the awk would work how its being used above. I am very new to it and the stuff I am reading is a bit confusing so far.
  #4 (permalink)  
Old 04-22-2009
LRoberts LRoberts is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 87
I am sooo close!!!

I am now doing this...
Code:
ps -ef | grep nco_p_syslog | grep -v grep | awk '{print $NF}' | awk -F_ '{print $2}' >> $OMNIHOME/bin/syslogfile.dat
Which gives this result....
Code:
dc000p.log
I just can not figure out how to cut the .log from the end :-(
  #5 (permalink)  
Old 04-22-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,788
Why not
Code:
ps -ef | awk -F. '/nco_p_syslog/ { print $NF }' > $OMNIHOME/bin/syslogfile.dat # Solaris
ps -ef | awk -F'_' '/nco_p_syslog/ { print substr($NF, 1, index($NF, ".")-1) }'  > $OMNIHOME/bin/syslogfile.dat # Linux
  #6 (permalink)  
Old 04-22-2009
LRoberts LRoberts is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 87
Hhhhmmm that gives me this result...
Code:
syslog/ { print substr($NF, 1, index($NF, "
dc000p
I only want to capture the dc000p part.
  #7 (permalink)  
Old 04-22-2009
kodak kodak is offline
Registered User
  
 

Join Date: Jun 2003
Posts: 51
Without trying very hard:

ps -ef | grep nco_p_syslog | grep -v grep | awk '{print $NF}' | awk -F_ '{print $2}' | cut -d '.' -f 1

Maybe? I don't have your output.
Sponsored Links
Closed Thread

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 07:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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