Results 1 to 5 of 5
Dear Group,
I am newbie to shell script programing. I was trying to write a script
which will compile all the .tex file in a folder as mention below:
for ...
- 09-03-2007 #1Just Joined!
- Join Date
- Sep 2007
- Posts
- 7
Shell script help
Dear Group,
I am newbie to shell script programing. I was trying to write a script
which will compile all the .tex file in a folder as mention below:
for f in *.tex; do latex $f; done;
mv *.tex /data/jay/success
mv *.dvi /data/jay/success
And this is working fine, but the issue is, if any .tex file is having
compilation error, my batch execution getting stuck. Can anybody help
me out to ignore the compilation error and jump to next file
compilation? And also, how to move all the error files with log file
to a different directory.
Thanking you with anticipation of your earliest reply.
...Jay
- 09-03-2007 #2Just Joined!
- Join Date
- Aug 2007
- Posts
- 37
One possibility is '--interaction=nonstopmode' :
But then the latex info file suggests:Code:for f in *.tex; do latex --interaction=nonstopmode "$f" done mv *.tex *.dvi /data/jay/success
Try them both and let us know if either of them work the way you want.Code:for f in *.tex; do latex "\scrollmode\input $f" done mv *.tex *.dvi /data/jay/success
- 09-03-2007 #3Just Joined!
- Join Date
- Sep 2007
- Posts
- 7
Thanks, but it is moving all the .tex files to success folder. Whereas, I am trying to put all .tex files which has compilation error to fail folder. Kindly suggest.
...Jay
- 09-03-2007 #4Just Joined!
- Join Date
- Aug 2007
- Posts
- 37
Okay, I misunderstood your first message.
The variable "$?" contains the exit status of the last command. If it contains '0' the command succeeded, if it contains any other number the command failed in some way. So we use that value to decide which directory to send the output files to:
Code:SUCCESS=$HOME/data/jay/success FAILURE=$HOME/data/jay/failure [[ ! -d "$SUCCESS" ]] && mkdir -p "$SUCCESS" [[ ! -d "$FAILURE" ]] && mkdir -p "$FAILURE" for FILE in *.tex; do latex --interaction=nonstopmode "$FILE" case $? in 0) mv "${FILE%.*}".{tex,dvi,log} "$SUCCESS" ;; *) mv "${FILE%.*}".{tex,dvi,log} "$FAILURE" ;; esac done
- 09-06-2007 #5Just Joined!
- Join Date
- Sep 2007
- Posts
- 7
Thanks a lot, its working fine...
...Jay


Reply With Quote