Solaris / Linux Issues with script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Solaris / Linux Issues with script
# 1  
Old 04-22-2009
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  
Old 04-22-2009
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  
Old 04-22-2009
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  
Old 04-22-2009
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  
Old 04-22-2009
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  
Old 04-22-2009
Hhhhmmm that gives me this result...
Code:
syslog/ { print substr($NF, 1, index($NF, "
dc000p

I only want to capture the dc000p part.
# 7  
Old 04-22-2009
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Xalan & Xerces issues for Oracle Linux 6.6 & Solarisstudio12.3 C++ compiler for Linux

Hi Team, I am facing issue while using Xalan & Xerces for my application. Below are my environment details i am using :- Platform:- Oracle Linux 6.6 Compiler :- solarisstudio12.3 C++ compiler for Linux Below are the versions of Xalan & Xerces source code used to build the shared object... (0 Replies)
Discussion started by: agrachirag
0 Replies

2. Shell Programming and Scripting

Porting script from Solaris to Linux

I have a script which has commands that are located in different paths on my Linux o/s than on Solaris. For example, to make uname work, I need to do it this way in Solaris: my $host= `/usr/bin/uname -n` But in Linux it is: my $host = `/bin/uname -n`I have this issue with at least 5... (8 Replies)
Discussion started by: newbie2010
8 Replies

3. Shell Programming and Scripting

ksh script migration from Solaris to Linux.

We are migrating some scripts (ksh) from Solaris 10 to Linux 2.6.32. Can someone share list of changes i need to take care for this ? Have found few of them but i am looking for a exhaustive list. Thanks. (6 Replies)
Discussion started by: Shivdatta
6 Replies

4. Shell Programming and Scripting

Script works with Linux not with Solaris

Hi I have the following script which works in Linux shell but gives issues with Sun OS Solaris 5.10, What i am trying to achieve here is we have a list of file names in list.txt file and we parse each file at a time for a particular pattern and copt next 4 lines after we hit the pattern to a... (6 Replies)
Discussion started by: Yugendra
6 Replies

5. Shell Programming and Scripting

Same script for Solaris,Linux,AX

Hi , I have a script which is running in Solaris. But my requirement got changed...this script has to run in all OS like Linux,AIX. I tried it but most of the command is not found in all these OS. Is there any way so that i can just modify some part and run it in all OS. (3 Replies)
Discussion started by: millan
3 Replies

6. Shell Programming and Scripting

convert script linux to solaris???

dear all how to convert my script like this Code: awk -F "," '{close(f);f=$1}{print > f".txt"}' sample.txt for using in solaris iam first in solaris so all my script in linux not alot of working in solaris thx for advice (2 Replies)
Discussion started by: zvtral
2 Replies

7. Solaris

Solaris 8 vs Solaris 10 compatibility issues !

Hello, I recently upgraded our system from Solaris 8 to 10. It seems couple of binaries crashed in the new server Solaris 10. Before digging too much on it , from theory it sounds like any binary that is built on Solaris 8 (using gmake) is supposed to be compatible with Solaris 10 , right ? ... (1 Reply)
Discussion started by: sudsa
1 Replies

8. Shell Programming and Scripting

Solaris Script Going To Linux

I am having an issue with the following command in Linux... penguinshrimp:/lcl/apps/Tivoli/omnibus_procedure_scripts>df -bhk /lcl/apps/Tivoli/omnibus_procedure_scripts | cut -d "y" -f1 | awk '{print$5}' df: invalid option -- b Try `df --help' for more information.... (1 Reply)
Discussion started by: LRoberts
1 Replies

9. Shell Programming and Scripting

Script works on Solaris, not on Linux

I'm in the same boat as Barbus - same exercis (https://www.unix.com/shell-programming-scripting/43609-processes-users.html) The following script works on a solaris server I have access to. It doesn't however, work on the companies Linux machine. Any idea what's up? I have very little shell... (1 Reply)
Discussion started by: Silverhood
1 Replies

10. Shell Programming and Scripting

Script works on Solaris, not on Linux

I'm in the same boat as Barbus - same exercis (https://www.unix.com/shell-programming-scripting/43609-processes-users.html) The following script works on a solaris server I have access to. It doesn't however, work on the companies Linux machine. Any idea what's up? I have very little shell... (0 Replies)
Discussion started by: Silverhood
0 Replies
Login or Register to Ask a Question