Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Windows - have program replace itself

by jdtoronto (Prior)
on Sep 27, 2004 at 19:47 UTC ( #394322=note: print w/replies, xml ) Need Help??


in reply to Windows - have program replace itself

Okay folks, here is the results of playing with this idea:

  • Don't trust Windows, well to be specific, don't trust Perl in Windows to return what you think it should return. In my case I am developing in Komodo, so when I have Komodo run the programme, the value of $0 is something else altogether!
  • If I use PerlApp from Komodo (which I do anyway) then $0 returns a sensibble value. BUT JediWizard the exec($0); doesn't work as you would expect. But purely using exec("appname.exe"); works just fine.
  • Now, sgifford: I have packaged the app using PerlApp. This is some testing code:
    unlink 'appname_old.exe'; rename ( 'appname.exe', 'appname_old.exe'); use Win32; my $localdir = Win32::GetCwd(); print "My idea of a local directory: " . $localdir . "\n"; print "I think I am program: $0 \n"; use Net::FTP; my $ftp = Net::FTP->new( "myftpserver.net", Timeout => 30, Debug => 0 ) or warn "Can't connect: $@\n"; $ftp->login( 'anonymous', 'guest') or die "Couldn't authenticate"; $ftp->cwd("/pub"); $ftp->type( "I" ); $ftp->get('appname.exe'); $ftp->quit; debug( "Quitting, restart programme please." ); exec("appname.exe");
    As you can see with the programme running I renamed the .exe file, and then copied a new file from the ftp server with the same name. So that all worked nicely.
  • Now waswas-fng suggests using PAR and running with parts of the programme remote. That's a neat idea. My application packages nicely with PAR and the idea of caching in-between is rather nice. I will lookinto it, thank you!
  • Now finally, Zero_Flop, thanks for the suggestion. Sadly, these folk are typical Windows users - ask them to open a command prompt and they go all glassy-eyed on you!
Once again to all of you, thank you!

jdtoronto

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2023-01-30 11:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?