Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a Unix shell script that needs to process different file type by calling another Unix shell script.
I put the main processing in a loop.

I found that after calling the other Unix shell script, the current script cannot use the current directory any more.

I put pwd and ls after calling the other shell script, I got:

cannot access parent directories  
total 0  

Is there a way to fix this?
Thanks!

Sample script, the called script never did anything about directories except cd:

#!/bin/ksh  
  
   typeset -i COMPANY_SEL  
   typeset -i loopstep  
  
   COMPANY_SEL=1  
   loopstep=6  
  
   until [ $loopstep -eq 0 ]; do  
  
      if [ $COMPANY_SEL -eq 1 ]; then  
         CMPY="C1"  
      elif [ $COMPANY_SEL -eq 2 ]; then  
         CMPY="C2"  
      elif [ $COMPANY_SEL -eq 3 ]; then  
         CMPY="C3"  
      elif [ $COMPANY_SEL -eq 4 ]; then  
         CMPY="C4"  
      elif [ $COMPANY_SEL -eq 5 ]; then  
         CMPY="C5"  
      elif [ $COMPANY_SEL -eq 6 ]; then  
         CMPY="C6"  
      fi  
  
      /home/me/script2.sh $CMPY  
      pwd  
      ls  
  
      COMPANY_SEL=$COMPANY_SEL+1  
      loopstep=$loopstep-1  
  
done  
  
exit 0
question from:https://stackoverflow.com/questions/66067079/lost-current-position-after-calling-another-unix-shell-script

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
153 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...