Solaris / Linux Issues with script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Solaris / Linux Issues with script
# 15  
Old 04-22-2009
So, why is the script returning just part of the output?
# 16  
Old 04-22-2009
Its really strange to me...

I do this from command line...
Code:
bluemarron:/lcl/apps/Tivoli/netcool/omnibus/bin>ps -ef | grep nco_p_syslog | grep -v grep | awk '{print $NF}' | awk -F. '{print $1}' | cut -d '_' -f 2

And the results are...
Code:
dc000p

Which is perfect.

Yet when I do the same thing from a script....
Code:
#!/bin/ksh
# Create and populate array of db syslog probes which are currently running
ps -ef | grep nco_p_syslog | grep -v grep | awk '{print $NF}' | awk -F. '{print $1}' | cut -d '_' -f 2  > $OMNIHOME/bin/syslogfile.dat
set -A syslog_array
syslogfile_name='syslogfile.dat'

The results in the dat file are....
Code:
/lcl/prd/data/dc000p/dump/bdump/alert_dc000p

# 17  
Old 04-22-2009
Just do:

ps -ef | grep nco_p_syslog | grep -v grep

from the command line. Then put that *same command* in a script and run it from the same place you're running the other script from.

#!/bin/sh
ps -ef | grep nco_p_syslog | grep -v grep

And compare the outputs. You're not going to find out what the difference is until you compare the raw output.

It's entirely possible that the results returned will be different depending on a lot of factors, you'll just have to adjust your script to account for those differences.
# 18  
Old 04-23-2009
Ok my 3rd full day at this... :-( This thing is driving me nuts!

If I run this myself from the command line....
Code:
ps -ef | grep nco_p_syslog | grep -v grep | awk '{print $NF}' | awk -F. '{print $2}'  > $OMNIHOME/bin/syslogfile.dat

The results in the dat file are...
Code:
dc000p

Which is perfect. However.....

If I let my script do the same thing....
Code:
#!/bin/ksh
# Create and populate array of db syslog probes which are currently running
ps -ef | grep nco_p_syslog | grep -v grep | awk '{print $NF}' | awk -F. '{print $2}'  > $OMNIHOME/bin/syslogfile.dat
set -A syslog_array
syslogfile_name='syslogfile.dat'

The results from the script in the dat file are....
Code:
/lcl/apps/Tivoli/netcool/omnibus/probes/linux2x86/syslog


Also this is the results of doing just a ps -ef | grep syslog | grep -v grep....
Code:
u@h:w> ps -ef | grep syslog | grep -v grep
root      4556     1  0 Mar18 ?        00:17:40 vxconfigd -x syslog
root      5307     1  0 Apr22 ?        00:00:00 /sbin/syslogd
tivoli   25474  9852  0 09:32 pts/2    00:00:00 tail -f syslogfile.dat
tivoli   27003  7618  0 09:35 pts/3    00:00:00 /lcl/apps/Tivoli/netcool/omnibus/probes/linux2x86/nco_p_syslog -manager dc000p -logfile /lcl/prd/data/dc000p/dump/bdump/alert_dc000p.log -propsfile /lcl/apps/Tivoli/netcool/omnibus/probes/linux2x86/syslog.dc000p.props


I don't get it... What am I doing wrong here? Smilie

Last edited by LRoberts; 04-23-2009 at 10:41 AM..
# 19  
Old 04-23-2009
Shell is ksh if that helps.
# 20  
Old 04-23-2009
Ok its fixed. The issue was that the script is so long I did not noticed that at the bottom this same dat file was being refilled so the old grep was replacing the new. :-)

Thanks for all the help!
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