LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-28-2005, 03:45 PM   #1
farmerjoe
Member
 
Registered: Oct 2004
Location: Texas
Distribution: Ubuntu - Home, RHEL4 - Server
Posts: 96

Rep: Reputation: 15
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
 
Old 04-28-2005, 03:49 PM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
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.
 
Old 04-28-2005, 04:04 PM   #3
farmerjoe
Member
 
Registered: Oct 2004
Location: Texas
Distribution: Ubuntu - Home, RHEL4 - Server
Posts: 96

Original Poster
Rep: Reputation: 15
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
 
Old 04-29-2005, 06:00 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Slack, Debian, Mint, Puppy, Raspbian
Posts: 3,474

Rep: Reputation: 222Reputation: 222Reputation: 222
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
it will split it for you and you can lose the 'cuts'
 
Old 04-29-2005, 02:44 PM   #5
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
Alternatively, try this:
Code:
bash -c "$LYNX -term=vt100 -cmd_script=$FILENAME"
 
Old 04-29-2005, 03:57 PM   #6
farmerjoe
Member
 
Registered: Oct 2004
Location: Texas
Distribution: Ubuntu - Home, RHEL4 - Server
Posts: 96

Original Poster
Rep: Reputation: 15
Hmm. I'll try both of your suggestions later today after work! Thanks for all your input. You guys are a great help.

-farmerjoe
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop ends unexpectedly after one run! trex_dk Programming 2 11-11-2005 04:49 AM
gaim quits unexpectedly Andramalech Linux - Newbie 4 11-17-2004 06:20 PM
XFree restarts unexpectedly triaydev Mandriva 4 10-19-2004 10:30 PM
I get logget out unexpectedly!! slice4e Linux - General 2 05-11-2003 10:43 PM
pppd keeps dieing unexpectedly sonikntails Linux - Software 3 05-05-2002 04:17 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration