T
Tom McDonough
I'm writing a back up script and want to put all files in directory
(MRIS) which are not a directory in their own right into a temporary
directory (TEMP).
I'm operating in Mac OS X 10.2.8 with the perl 5.6 that came with the
distro and the cp is 4th Berkeley Distribution April 18, 1994
From the shell my cp is working as I expect but when I use cp in a
perl script in a system call I get odd - to my mind - results.
When the script is run from the parent directory, this:
$copy = `cp mris/$thisone mris/temp/$thisone`;
Elicits this:
usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target
cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory
sh: mris/temp/test.pl: No such file or directory
And this:
$copy = `cp mris/$thisone mris/temp`;
Results in this:
usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target
cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory
sh: mris/temp: is a directory
When I go down to the mris directory and run the script, this
$copy = `cp $thisone temp`;
Results in this:
usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target
cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory
sh: temp: command not found
BTW: cd doesn't seem to work in a system call either. Script is
copied below.
Stymied in Stanton
*******************
#!/usr/bin/perl
# this script is located in mris
@ls = `ls -l`;
foreach $file (@ls) {
if ($file =~ /^d/) {
@file = split / /, $file;
$thisone = pop @file;
print "$thisone";
}
else {
@file = split / /, $file;
if (!($file =~ 'total')) {
$thisone = pop @file;
$copy = `cp $thisone temp/$thisone`;
}
}
}
(MRIS) which are not a directory in their own right into a temporary
directory (TEMP).
I'm operating in Mac OS X 10.2.8 with the perl 5.6 that came with the
distro and the cp is 4th Berkeley Distribution April 18, 1994
From the shell my cp is working as I expect but when I use cp in a
perl script in a system call I get odd - to my mind - results.
When the script is run from the parent directory, this:
$copy = `cp mris/$thisone mris/temp/$thisone`;
Elicits this:
usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target
cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory
sh: mris/temp/test.pl: No such file or directory
And this:
$copy = `cp mris/$thisone mris/temp`;
Results in this:
usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target
cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory
sh: mris/temp: is a directory
When I go down to the mris directory and run the script, this
$copy = `cp $thisone temp`;
Results in this:
usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target
cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory
sh: temp: command not found
BTW: cd doesn't seem to work in a system call either. Script is
copied below.
Stymied in Stanton
*******************
#!/usr/bin/perl
# this script is located in mris
@ls = `ls -l`;
foreach $file (@ls) {
if ($file =~ /^d/) {
@file = split / /, $file;
$thisone = pop @file;
print "$thisone";
}
else {
@file = split / /, $file;
if (!($file =~ 'total')) {
$thisone = pop @file;
$copy = `cp $thisone temp/$thisone`;
}
}
}