473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Error returned on Unix 'mv' system call.

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,
Jan 8 '07 #1
2 4057
miller
1,089 Expert 1GB
Instead of the system mv command, you should instead use File::Copy qw(move).

http://perldoc.perl.org/File/Copy.html

The primary reason for this is because this will allow you to get meaningful error messages whenever something goes wrong. Same is true of the rename function. Just look in $! for the error cause.
Jan 9 '07 #2
thanks.

I figured out the $! return variable, and have tested okay using the rename with meaningful results.
Jan 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
2
by: Anthony | last post by:
I have an inventory database that Im trying to create a report out of the IP address are a lookup on a seperat table but I keep getting the above error can I change the table row to something to...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
8
by: ST | last post by:
Hello everyone, Can anyone help me with this error above when I debug my web app project in vstudio.net?? I can't figure it out! It was working fine for months, and now all of a sudden it's not!!...
4
by: wqyuwss | last post by:
Hi, We have several core dumps in our product. These core dump can be reproduced in the same place. That is system function call std::basic_istream<char,std::char_traits<char>>::getline. The...
5
by: Shuaib | last post by:
Hi! I have a python script which returns an Integer value. How do I call this script from a C programe, and use the result returned? Thanks for your time.
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
9
by: DanielJohnson | last post by:
I am wondering where does the value returned by main goes. Suppoes main returns some number say 42, where is it stored. Supposed a shell script call a C program and the program returns the value...
2
by: akhilesh.noida | last post by:
I am trying to compile glibc-2.5 for ARM based board. But I am getting errors while configuring it. Please check and give your inputs for resolving this. configure command : $...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.