Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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\ unable to copy to C:\progra~1\apache~1\apa +che\conf\gbrowse.conf\plugins\ : 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;

Project coordinator of the Generic Model Organism Database Project

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

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

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

    How do I use this?Last hourOther CB clients
    Other Users?
    Others scrutinizing the Monastery: (6)
    As of 2024-07-18 04:40 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found

      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.