Readers:


I'm writing in regard to ksh scripts I wrote to the ksh88 standards which have 
run for years on many HP-UX/PA-RISC and Solaris/Sparc platforms, and, even a 
few Linux/x86_64) platforms ... until this week. Upon running the scripts on 
CentOS 6.4/x86-x64 with Korn shell "Version AJM 93u+ 2012-08-01", non-null 
values being returned to a calling function are sometimes retrieved by the 
caller as null values.



Specifically, in the edited excerpts following, the variable ToDo always 
contains a value in fSendReqToSvr prior to fSendReqToSvr returning. When 
fSendReqToSvr returns in fGetFileStatusFromSvr, Todo is often assigned a null 
value. The context of this script is as a child invoked by another ksh script 
run from cron. I've included the code reassigning stdout and stderr on the 
chance this is somehow significant.



What don't I understand?



OS: CentOS-6.4 (x86-64) Development Installation Korn Shell: Version: AJM 93u+ 
2012-08-01 Package: Ksh.x86_64 20120801-10.el6







...



function fLogOpen



{



   ...



   exec 3>$1   #C# Assigned Fd 3 to a log file





   #C# stdout and stderr are redirected to log file as insurance that



   #C# no "errant" output from script (1700 lines) "escapes" from script.



   #C# stdout and stderr restored in fLogClose.



   exec 4>&1



   exec 1>&3



   exec 5>&2



   exec 2>&3



   ...



}







...







#C# Invokes curl on behalf of caller and evaluates the outcome, returning



#C# a string specifying what the caller should do.



function fSendReqToSvr



{



   typeset Err=0 ... \



           ToDo=CONTINUE ... \



           CL="$2" ...



   Typeset -I iSecsLeft=$1 iSleepSecs=3







   ...



   curl $CL > $CurlOutFFS 2>&1 &



   gCurlPId=$!



   while (( iSecsLeft > 0 )) ; do



      ...



      #C# Sleep N secs, check status of curl with "kill -0 $gCurlPId"



      #C# and if curl exited, get return code from "wait $gCurlPId".



      ...



      (( iSecsLeft = iSecsLeft - iSleepSecs ))



   done



   ...



   #C# Evaluate curl return code and contents of CurlOutFFS file to



   #C# determine what to set ToDo to.  ToDo is - without exception -



   #C# assigned a string like "CONTINUE", "NEXT_FILE", etc.



   ...





   #C#



   print -n -- "$ToDo"   #C# ToDo confirmed to always have a value here



   return $Err



}







...







function fGetFileStatusFromSvr



{



   typeset Err=0 ... \



           ToDo=CONTINUE ... \



           ...



   ...



   ToDo=$( fSendReqToSvr "$iSessMaxSecs" "$CurlCmdLine" )



   Err=$?



   #C# ToDo contains null here



   ...





   return $Err



}







_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users

Reply via email to