Error returned on Unix "mv" system call.
Error returned on Unix "mv" system call.
am 08.01.2007 19:37:38 von Mark.Cummings
I am migrating an Oracle 9i to Oracle 10g database, and Perl 5.0.4 to
Perl 5.8.7 in Sun Solaris environment.
Using Perl 5.8.7, the following legacy code segment is returning a '-1'
return code on the system call to execute the 'mv' command. Note that
the mv request is across directories.
sub move_inproc
{
print "sub move_inproc\n";
`mv $histhome/dat/inbound/$filename $histhome/dat/inproc/$filename`;
if ($? !=3D0)
{
&fatal_error ("913", "ERROR - Cant Move
$histhome/dat/inbound/$filename to $histhome/dat/inproc");
}
else
{
&log_msg("000", "File $filename successfully moved to
$histhome/dat/inproc dir");
}
Interestingly, when the code executes the fatal_error routine the Perl
rename function works fine (also across directories).
sub fatal_error
{
....
rename ("$histhome/dat/inproc/$filename",
"$histhome/dat/inbad/$filename");
if ($? !=3D0)
{
&log_msg ("523", "WARNING - Cant Move
$histhome/dat/inproc/$filename to $histhome/dat/inbad");
}
else
{
&log_msg("000", "File $filename moved to $histhome/dat/inbad
dir");
....
}
I can find no reason why the system call to the 'mv' command fails, and
the Perl 'rename' function works, and better yet, why the 'mv' system
call is used in one sub-module, and the Perl 'rename' function in
another sub-module.
I am planning on replacing the 'mv' system call with the Perl 'rename'
function, unless of course you experts out there tell me different.
Comments welcome; thanks,
Mark Cummings
Re: Error returned on Unix "mv" system call.
am 08.01.2007 21:42:17 von jonathan.leffler
------=_Part_56608_22799816.1168288937448
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
If rename works and mv doesn't, use rename everywhere.
It is quicker, simpler, less insecure, and more consistent too. Actually, I
can't think of a reason to keep mv around.
On 1/8/07, Mark.Cummings@wellsfargo.com
wrote:
>
>
> I am migrating an Oracle 9i to Oracle 10g database, and Perl 5.0.4 to
> Perl 5.8.7 in Sun Solaris environment.
>
> Using Perl 5.8.7, the following legacy code segment is returning a '-1'
> return code on the system call to execute the 'mv' command. Note that
> the mv request is across directories.
>
> sub move_inproc
> {
> print "sub move_inproc\n";
> `mv $histhome/dat/inbound/$filename $histhome/dat/inproc/$filename`;
> if ($? !=0)
> {
> &fatal_error ("913", "ERROR - Cant Move
> $histhome/dat/inbound/$filename to $histhome/dat/inproc");
> }
> else
> {
> &log_msg("000", "File $filename successfully moved to
> $histhome/dat/inproc dir");
> }
>
> Interestingly, when the code executes the fatal_error routine the Perl
> rename function works fine (also across directories).
>
> sub fatal_error
> {
> ...
> rename ("$histhome/dat/inproc/$filename",
> "$histhome/dat/inbad/$filename");
> if ($? !=0)
> {
> &log_msg ("523", "WARNING - Cant Move
> $histhome/dat/inproc/$filename to $histhome/dat/inbad");
> }
> else
> {
> &log_msg("000", "File $filename moved to $histhome/dat/inbad
> dir");
> ...
> }
>
> I can find no reason why the system call to the 'mv' command fails, and
> the Perl 'rename' function works, and better yet, why the 'mv' system
> call is used in one sub-module, and the Perl 'rename' function in
> another sub-module.
>
> I am planning on replacing the 'mv' system call with the Perl 'rename'
> function, unless of course you experts out there tell me different.
>
> Comments welcome; thanks,
>
> Mark Cummings
>
>
--
Jonathan Leffler #include
Guardian of DBD::Informix - v2005.02 - http://dbi.perl.org
"I don't suffer from insanity - I enjoy every minute of it."
------=_Part_56608_22799816.1168288937448--
Re: Error returned on Unix "mv" system call.
am 08.01.2007 22:28:16 von shaild
rename didnot work across the file system as it states
in Perldoc, in that case mv command is a saver..
--- Jonathan Leffler
wrote:
> If rename works and mv doesn't, use rename
> everywhere.
>
> It is quicker, simpler, less insecure, and more
> consistent too. Actually, I
> can't think of a reason to keep mv around.
>
> On 1/8/07, Mark.Cummings@wellsfargo.com
>
> wrote:
> >
> >
> > I am migrating an Oracle 9i to Oracle 10g
> database, and Perl 5.0.4 to
> > Perl 5.8.7 in Sun Solaris environment.
> >
> > Using Perl 5.8.7, the following legacy code
> segment is returning a '-1'
> > return code on the system call to execute the 'mv'
> command. Note that
> > the mv request is across directories.
> >
> > sub move_inproc
> > {
> > print "sub move_inproc\n";
> > `mv $histhome/dat/inbound/$filename
> $histhome/dat/inproc/$filename`;
> > if ($? !=0)
> > {
> > &fatal_error ("913", "ERROR - Cant Move
> > $histhome/dat/inbound/$filename to
> $histhome/dat/inproc");
> > }
> > else
> > {
> > &log_msg("000", "File $filename successfully
> moved to
> > $histhome/dat/inproc dir");
> > }
> >
> > Interestingly, when the code executes the
> fatal_error routine the Perl
> > rename function works fine (also across
> directories).
> >
> > sub fatal_error
> > {
> > ...
> > rename ("$histhome/dat/inproc/$filename",
> > "$histhome/dat/inbad/$filename");
> > if ($? !=0)
> > {
> > &log_msg ("523", "WARNING - Cant Move
> > $histhome/dat/inproc/$filename to
> $histhome/dat/inbad");
> > }
> > else
> > {
> > &log_msg("000", "File $filename moved to
> $histhome/dat/inbad
> > dir");
> > ...
> > }
> >
> > I can find no reason why the system call to the
> 'mv' command fails, and
> > the Perl 'rename' function works, and better yet,
> why the 'mv' system
> > call is used in one sub-module, and the Perl
> 'rename' function in
> > another sub-module.
> >
> > I am planning on replacing the 'mv' system call
> with the Perl 'rename'
> > function, unless of course you experts out there
> tell me different.
> >
> > Comments welcome; thanks,
> >
> > Mark Cummings
> >
> >
>
>
> --
> Jonathan Leffler
> #include
> Guardian of DBD::Informix - v2005.02 -
> http://dbi.perl.org
> "I don't suffer from insanity - I enjoy every minute
> of it."
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: Error returned on Unix "mv" system call.
am 10.01.2007 14:41:26 von david
Shail Dahal wrote:
> rename didnot work across the file system as it states
> in Perldoc, in that case mv command is a saver..
In that case, use File::Copy, which is a core module, and someone else
has already dealt with the fiddly issues of making it works everywhere,
all the time.
David
> --- Jonathan Leffler
> wrote:
>
>> If rename works and mv doesn't, use rename
>> everywhere.
>>
>> It is quicker, simpler, less insecure, and more
>> consistent too. Actually, I
>> can't think of a reason to keep mv around.
Re: Error returned on Unix "mv" system call.
am 10.01.2007 16:37:30 von jseger
On 1/10/07, David Landgren wrote:
> Shail Dahal wrote:
> > rename didnot work across the file system as it states
> > in Perldoc, in that case mv command is a saver..
>
> In that case, use File::Copy, which is a core module, and someone else
> has already dealt with the fiddly issues of making it works everywhere,
> all the time.
>
> David
>
> > --- Jonathan Leffler
> > wrote:
> >
> >> If rename works and mv doesn't, use rename
> >> everywhere.
> >>
> >> It is quicker, simpler, less insecure, and more
> >> consistent too. Actually, I
> >> can't think of a reason to keep mv around.
>
>
>
I can't think of a reason why this is being discussed on the dbi-users
mailing list. Can we either move this off line or take it to
perlmonks or something?
--
------------------------------------------------------------ --------------------------------------------------
The darkest places in hell are reserved for those who maintain their
neutrality in times of moral crisis.
Dante Alighieri (1265 - 1321)
They who would give up an essential liberty for temporary security,
deserve neither liberty or security.
Benjamin Franklin
Our lives begin to end the day we become silent about things that matter.
Martin Luther King
The right of the people to be secure in their persons, houses, papers,
and effects, against unreasonable searches and seizures, shall not be
violated, and no warrants shall issue, but upon probable cause,
supported by oath or affirmation, and particularly describing the
place to be searched, and the persons or things to be seized.
Amendment IV to the Constitution of the United States
------------------------------------------------------------ --------------------------------------------------