What would cause a while loop to unexpectedly end?
I have a script that implements a "lynx -cmd-script=" function. When the script is run with the lynx function, the while loop does not loop, but instead the script exits. The script runs fine if I take the lynx function out. Anyone have any idea what could cause this. I am sure it is not a syntax problem or anything like that.
-farmerjoe |
Please post at least the language that the script is written in (BASH/CSH/Perl/Pyton/KSH/SH/…). A minimal test version of the script will help to debug the problem too.
Some languages will take an implicit return value from a function, which may effect the exit condition. If it's at the end of the loop, you might be exec()ing it rather than system()ing it, and discarding the entire process that's looping. Or you may have a wild pointer that's modifying the exit flag. Without seeing code, there's no real way to tell. |
Script is written is bash. Heres the basic layout
LYNX="/usr/bin/lynx" FILENAME="blah.txt" echo "MYSQL STATEMENT HERE" | mysql > $FILE #$FILE contains a list of new files to download cat $FILE | while read LINE do VAR1=`echo line | cut -f1` VAR2=`echo line | cut -f2` $LYNX -term=vt100 -cmd_script=$FILENAME http://www.BLAH.com done Its a lot more complicated than that, but I can take that lynx statement out and the script will loop fine. The other funny thing is that the lynx statement only screws up part of the time, i've found that sometimes it works perfectly. Its very weird. I have been running lynx cmd-scripts in bash scripts for a long time and never run into anything like this. -farmerjoe |
wouldn't Lynx be taking over stdin from the read, llike vi would?
why don't you make the script first then execute Lynx? Or use ftp or wget maybe? btw, did you know you can do: Code:
cat $FILE | read VAR1 VAR2 VAR3 |
Alternatively, try this:
Code:
bash -c "$LYNX -term=vt100 -cmd_script=$FILENAME" |
Hmm. I'll try both of your suggestions later today after work! Thanks for all your input. You guys are a great help.
-farmerjoe |
All times are GMT -5. The time now is 07:59 AM. |