Sponsored Content
Full Discussion: ksh behavior change on RHEL5
Top Forums Shell Programming and Scripting ksh behavior change on RHEL5 Post 302416776 by bwhitehd on Tuesday 27th of April 2010 04:52:33 PM
Old 04-27-2010
You're correct, cron is not the issue specifically. It's the fact that the assigned value is one more than it should be.

Code:
#!/bin/ksh

echo $0
SCRIPT=${0##*/}
echo $SCRIPT
echo "IFS=xx${IFS}xx"
echo "PS=$(which ps)"
echo "GREP=$(which grep)"
echo "PGREP=$(which pgrep)"
echo "WC=$(which wc)"

/bin/ps -ef | /bin/grep -v grep | /bin/grep $SCRIPT
/bin/ps -ef | /bin/grep -v grep | /bin/grep $SCRIPT | /usr/bin/wc -l

echo "-----------"
 
/bin/ps -ef | /bin/grep -v grep | /bin/grep -c $SCRIPT
proc1=`/bin/ps -ef | /bin/grep -v grep | /bin/grep -c $SCRIPT`
echo "proc1=$proc1"
 
echo "-----------"
/bin/ps -ef | /bin/grep -v grep | /bin/grep -c $SCRIPT
proc2=$( (ps -ef | /bin/grep -v grep | /bin/grep -c $SCRIPT) )
echo "proc2=$proc2"
 
echo "-----------"
/usr/bin/pgrep $SCRIPT | /usr/bin/wc -l
proc3=$(/usr/bin/pgrep $SCRIPT | /usr/bin/wc -l)
echo "proc3=$proc3"

echo "-----------"
/bin/ps -ef | /bin/grep -v grep | /bin/grep $SCRIPT
/bin/ps -ef | /bin/grep -v grep | /bin/grep $SCRIPT | /usr/bin/wc -l

output from patched
Code:
> ./test2.ksh
./test2.ksh
test2.ksh
IFS=xx 
xx
PS=/bin/ps
GREP=/bin/grep
PGREP=/usr/bin/pgrep
WC=/usr/bin/wc
brian     3728   553  0 15:48 pts/8    00:00:00 /bin/ksh ./test2.ksh
1
-----------
1
proc1=2
-----------
1
proc2=2
-----------
1
proc3=2
-----------
brian     3728   553  0 15:48 pts/8    00:00:00 /bin/ksh ./test2.ksh
1

output from non-patched
Code:
> ./test2.ksh
./test2.ksh
test2.ksh
IFS=xx 
xx
PS=/bin/ps
GREP=/bin/grep
PGREP=/usr/bin/pgrep
WC=/usr/bin/wc
brian    11485 10981  0 15:50 pts/1    00:00:00 /bin/ksh ./test2.ksh
1
-----------
1
proc1=1
-----------
1
proc2=1
-----------
1
proc3=1
-----------
brian    11485 10981  0 15:50 pts/1    00:00:00 /bin/ksh ./test2.ksh
0

The last number of the non-patched system is incorrect here. "0" should be "1"
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh parameter --- change

I am reading a file into a parameter in my program typeset nums_type if the contents of nums_type = asdfghbqwerty how do make a new paremeter eqaul to the 7th character of nums_type. like ${type} = b (2 Replies)
Discussion started by: frank
2 Replies

2. Shell Programming and Scripting

Strange behavior from 'read' statements. (ksh - but could be same on other shells)

I'm getting rather frustrated with an interactive script I'm writing. The script is divided up, with section for setting variable at the top, then functions (which make up most of the script) then basically a line at the end which calls the first function- the program moves between the... (5 Replies)
Discussion started by: alexop
5 Replies

3. UNIX for Dummies Questions & Answers

Change to ksh shell

Hi everyone: Mi default shell is sh, i need to set the TMOUT variable so i need to change the shell to ksh, I change the /etc/profile file as follows, but when i do an echo $0 stll sh been the shell: # more /etc/profile # # (c) Copyright 1990, OPEN SOFTWARE FOUNDATION, INC. # ALL RIGHTS... (2 Replies)
Discussion started by: irasela
2 Replies

4. UNIX for Dummies Questions & Answers

How can I change the behavior of the mouse in Terminal?

Hi, I hope I'm posting in the correct forum, so here goes. I would like for the mouse right/left click to work in Terminal (OSX) as it does in Putty. For instance, when I double click 'log' in file.log.gz, only the log part is highlighted (in Terminal), while in Putty the entire file name is... (0 Replies)
Discussion started by: TheChemist
0 Replies

5. UNIX for Advanced & Expert Users

How to change the permissions of ksh?

Suppose, I want to execute unix commands. For that I have to go to ksh, but if I don't have execute permission to ksh itself then is there any way to change the permission of ksh? chmod command does not work for this because, I don't have permission to ksh itself... :) Let me know, if you have... (3 Replies)
Discussion started by: ponnuvel
3 Replies

6. Shell Programming and Scripting

ksh script to change passwd

Hello All, I am trying to change a user passwd (one time password): cat /tmp/passwd mnop1234 mnop1234 #passwd abcd < /tmp/passwd (for some reason, it is not able to input the password from /tmp/passwd and comes back with "New Password: ") Is there a work around except using "expect". ... (1 Reply)
Discussion started by: solaix14
1 Replies

7. Shell Programming and Scripting

change output format using ksh

I have a script that reaches out to several systems and pulls back infomation in serveral files. I would like to take the infomation returned and reformat it so I can export it to excel. Below is current output: File1:item1:abc=1 File1:item2:efg File2:item1:ab=1 File2:item2:efg... (3 Replies)
Discussion started by: oldman2
3 Replies

8. Shell Programming and Scripting

ksh behavior in scripts spawned w/nohup

I have a need to run any number of identical scripts simultaneously, so I've created a driver script which reads a template script, edits these appropriately and then submits them via nohup. The spawned scripts all check to see at some point how many of their number are running and once the count... (7 Replies)
Discussion started by: safedba
7 Replies
getusershell(3C)					   Standard C Library Functions 					  getusershell(3C)

NAME
getusershell, setusershell, endusershell - get legal user shells SYNOPSIS
#include <unistd.h> char *getusershell(void); void setusershell(void); void endusershell(void); DESCRIPTION
The getusershell() function returns a pointer to a legal user shell as defined by the system manager in the file /etc/shells. If /etc/shells does not exist, the following locations of the standard system shells are used in its place: /bin/bash /bin/csh /bin/jsh /bin/ksh /bin/pfcsh /bin/pfksh /bin/pfsh /bin/sh /bin/tcsh /bin/zsh /sbin/jsh /sbin/pfsh /sbin/sh /usr/bin/bash /usr/bin/csh /usr/bin/jsh /usr/bin/ksh /usr/bin/pfcsh /usr/bin/pfksh /usr/bin/pfsh /usr/bin/sh /usr/bin/tcsh /usr/bin/zsh /usr/xpg4/bin/sh The getusershell() function opens the file /etc/shells, if it exists, and returns the next entry in the list of shells. The setusershell() function rewinds the file or the list. The endusershell() function closes the file, frees any memory used by getusershell() and setusershell(), and rewinds the file /etc/shells. RETURN VALUES
The getusershell() function returns a null pointer on EOF. BUGS
All information is contained in memory that may be freed with a call to endusershell(), so it must be copied if it is to be saved. SunOS 5.10 30 Aug 2004 getusershell(3C)
All times are GMT -4. The time now is 07:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy