I guess Mac has default bash. Then I copy my code to another comp and run it...And it gives me an error like "bad substitution"....
How I can change my code??? Never had before this kind of situation. Help please.
if [ -f "/Users/Natalie/lastserial" ]
then
n=$(sort /Users/Natalie/lastserial | tail -1)
fourthoct=${n:0:4}
thirdoct=${n:4:2}
thirdoct=${thirdoct#0}
secondoct=${n:6:2}
secondoct=${secondoct#0}
firstoct=${n:8:2}
firstoct=${firstoct#0}
if [ $((++firstoct)) -eq 100 ]
then
firstoct=0
if [ $((++secondoct)) -eq 32 ]
then
secondoct=0
if [ $((++thirdoct)) -eq 13 ]
then
thirdoct=0
((++fourthoct))
fi
fi
fi
printf "%04d%02d%02d%02d\n" $fourthoct $thirdoct $secondoct $firstoct > '/Users/Natalie/lastserial'
else
echo ` date +%Y%m%d`"00" >'/Users/Natalie/lastserial'
fi
At the top of you script, include this line (right beneath the shebang line):
set -x
That turns debug mode on. When you run your script from the command line, it will execute step by step and stop where it finds an error. That will give you a clue as to what's wrong.
Do not hesitate to get back to us with the error that you find.
Additionaly to this weird post, i mean...
You use SH on a WinOS on a Mac... hmm....
The topic, subject, content (lost in translation) of your scripts, seems VERY MUCH similar to: Output pipes and incrementing
As in: The same homework, diffrent approaches.