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