[Israel.pm] Renaming folder using perl
semuelf at 012.net.il
Tue May 5 15:26:21 PDT 2009
A lot of discussion here about your question, but still added my bits:
Windows won't let you touch a directory that a program is running from.
If you want to see it in action, just open command prompt to some
directory, and try to rename it and delete it. it fails.
It is never a good idea to touch the file of a running program. it makes
debugging a nightmare.
my suggestion: make the main program to an updater program. put the
actual agent in an 'agent' directory bellow it. when the main program
starts, it should check for update, download it to new_agent, verify the
download, (checksum / CRC, for safety), rename the old agent to
'backup_agent' (what is already exists?) and the new agent to 'agent'.
Then, it should run the agent itself.
That way, you won't have any of the problems discussed.
Berler Chanan wrote:
> Hi All,
> I need to write a script that renames the folder the script is running from:
> The idea to rename the current folder to a back_<localtime>, then download a
> zip file and extract it
> (the main Idea to replace the current agent with another nagios agent).
> Problem: how can I rename the current folder the script is running from ?
> trying rename function fails (like system rename).
> Perl mailing list
> Perl at perl.org.il
More information about the Perl