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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello Fine Monks,

In an effort to make my webapp install cross-platform, I have written several small Perl scripts that do some of the moving of files for 'make install'. These scripts work fine when installing on a Linux box, and they work when installing on a Win2k box, as long as the files that it is trying to install don't already exist in the install location. If the files are alread there, the script dies thusly:

conf\plugins\BatchDumper.pm unable to copy to C:\progra~1\apache~1\apa +che\conf\gbrowse.conf\plugins\BatchDumper.pm : Bad file descriptor NMAKE : fatal error U1077: 'C:\WINNT\system32\cmd.exe' : return code ' +0x9' Stop.
Now, I suppose I could check for the existence of the file, unlink it and then copy it, but that seems quite ugly to me, when File::Copy's copy should work just fine. Any suggestions? The code follows:
#!/usr/bin/perl -w use strict; #Perform installation of gbrowse apache configuration files use File::Copy; use Bio::Root::IO; # get configuration stuff from command line my $dir = $ARGV[0]; # use Bio::Root::IO now #my $delim = '/'; #if ($Config{'osname'} =~ /win/i && $Config{'osname'} !~ /darwin/i ) { # $dir =~ s!\/!\\!g; # $delim = '\\'; #} #start the installation... print "Installing sample configuration files...\n"; if (! (-e $dir)) { mkdir($dir,0777) or die "unable to make $dir directory\n"; } opendir CONFDIR, "conf" or die "unable to opendir conf\n"; while (my $conffile = readdir(CONFDIR) ) { my $localfile = Bio::Root::IO->catfile('conf', $conffile); if (-f $localfile) { my $installfile = Bio::Root::IO->catfile($dir, $conffile); if (-f $installfile) { print " Found $conffile in $dir. Skipping...\n"; } else { copy($localfile, $installfile) or die "unable to copy to $installfile\n"; } } } closedir CONFDIR; my $plugindir = Bio::Root::IO->catfile($dir, "plugins"); if (! (-e $plugindir)) { mkdir($plugindir,0777) or die "unable to mkdir $plugindir\n"; } opendir PLUGINS, "conf/plugins" or die "unable to opendir ./conf/plugi +ns\n"; while (my $pluginfile = readdir(PLUGINS) ) { my $localfile = Bio::Root::IO->catfile('conf/plugins',$pluginfile) +; if (-f $localfile) { my $installfile = Bio::Root::IO->catfile($plugindir, $pluginfi +le); copy($localfile, $installfile) or die "unable to copy to $installfile\n"; } } closedir PLUGINS; my $langdir = Bio::Root::IO->catfile($dir, 'languages'); if (! (-e $langdir)) { mkdir($langdir,0777) or die "unable to mkdir $langdir\n"; } opendir LANGS, "conf/languages" or die "unable to opendir ./conf/langu +ages\n"; while (my $langfile = readdir(LANGS)) { my $localfile = Bio::Root::IO->catfile("conf/languages", $langfile +); if (-f $localfile) { my $installfile = Bio::Root::IO->catfile($langdir, $langfile); copy($localfile, $installfile) or die "unable to copy to $installfile\n"; } } closedir LANGS;

Thanks,
Scott
Project coordinator of the Generic Model Organism Database Project


In reply to File::Copy dying on Win2k when target file already there by scain

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-06-20 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.