Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

get.bat halts

by PhilHibbs (Hermit)
on Aug 08, 2007 at 11:56 UTC ( [id://631288]=perlquestion: print w/replies, xml ) Need Help??

PhilHibbs has asked for the wisdom of the Perl Monks concerning the following question:

I'm downloading a sequence of files using the "get.bat" that comes with ActiveState Perl 5.8.1 (build 807, probably getting a bit out of date now). My perl script generates the command line parameters and uses system() to run the get.bat command. Everything goes fine for 20 or 30 files then it just stops with a 0 byte file and when I do Ctrl-C I get a dialog box "perl.exe - Application Error" - "The instruction at "0x3400d894" referenced memory at "0x000000c". etc."

After Ctrl-C, I can't delete the file, it's being used. The Command Prompt box behaves a little oddly, sometimes I press Enter and I don't get the C:\> prompt, I have to press Enter again to get it. If I press Ctrl-C again, the Command Prompt goes back to normal and I can delete the file.

If I re-run my script to pick up where it left off, it hangs again on the same file. Reboot the PC, and everything's fine.

Any ideas?

Replies are listed 'Best First'.
Re: get.bat halts
by Corion (Patriarch) on Aug 08, 2007 at 12:01 UTC

    Instead of using get.bat, which likely is the pl2bat-ified version of the GET utility that comes with LWP, consider using LWP::Simple's mirror subroutine. Or maybe use wget for your downloading.

      Thanks, I hadn't heard of LWP, its name isn't exactly obvious.
        Q:\>perldoc GET ... SEE ALSO lwp-mirror, LWP ...

        The nice thing about Perl programs is that you can look at the source for further hints

Re: get.bat halts
by BrowserUk (Patriarch) on Aug 08, 2007 at 12:48 UTC

    By the way. If you have to ^C it and perl goes bellyup again, immediately bring up the task manager you should be able to see the child perl process that is still running when the parent died and kill it. That would sort out the messed up cmd session.

    In the long term, rather than running perl from a cmd session, then shelling out from that to start another cmd session which starts another perl to use lwp to do the download, you'd be much better off to cut out the two middlemen and just use:

    use LWP::Simple; for ( @urls ) { getstore( $theUrl, $theOutputFile ) or warn "Failed to fetch $theU +rl: $!\n"; }

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      I have noticed the Windows version of AS Perl tend to lock files hard. You need to kill the perl that has the file open before you can write or delete the file.

      I had this problem with Archive::Zip... I have to close each zip member, and then the zip before I can even rename the zip file!

Re: get.bat halts
by BrowserUk (Patriarch) on Aug 08, 2007 at 12:22 UTC

    Try adding -e -S and -x to your command lines and redirect stderr to a file. If you do not understand the output, try postign that here. Someone may see something useful.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://631288]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-23 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found