Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ksh93 lost variables

Status
Not open for further replies.

slamcorp

MIS
Jan 31, 2003
19
US
i am running a script in a ksh93 shell that appears to cross its 'input variables' when the script runs twice at the same time. is there a way to prevent this? i need it to run simultaneously... here are some clips;
#!/usr/bin/ksh93
# Seperate file path and first search argument.
logpath="/usr/work/wms/backup"
timestmp=`date +'%m%d%C%y%H%M%S'`
maxgrab="$1"
shift 1
arglength=$(echo "$1"|awk -F "/" '{print NF}')
argpath=$(echo "$1"|cut -f -$((arglength - 1)) -d "/")
argbackup="$(echo "$1"|cut -f -$((arglength - 2)) -d "/")/backup"
argone=$(echo "$1"|cut -f ${arglength} -d "/")
shift 1
args="${argone} $@"
echo "$timestmp $maxgrab $arglength $argpath $argbackup $argone $args " >> /usr/log/GCS2.log

and some log output;
ok-
10302003063037 2000 8 /usr/sap/work/wms/import/inv /usr/sap/work/wms/import/backup ia ia iman isc

ok-
10302003063037 2000 8 /usr/sap/work/wms/import/inv /usr/sap/work/wms/import/backup ir ir

ok-
10302003063138 2000 8 /usr/sap/work/wms/import/inv /usr/sap/work/wms/import/backup lr
lost vars, time variable munched and path-
10302003063538 2000 8
302003063538 /backup iman isc
8

lost time var mixup-
302003063538 2000 8 /usr/sap/work/wms/import/inv /usr/sap/work/wms/import/backup ir ir


any help appreciated...
 
use local variables inside a function:

function myfunc {
typeset var1=localvalue1
typeset var2=localvalue2
}
var1=globalvalue1
var2=globalvalue2

variables are passed into the function from the calling script but are not passed back up when defined using typeset. if you just do "var2=localvalue2" then it will change the global instance.

IBM Certified -- AIX 4.3 Obfuscation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top