473,387 Members | 1,492 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,387 software developers and data experts.

Perl System call error

3
I am trying to make several system calls via Perl on a Windows box.

First command "rmdir ....". This gives me return code of 0. GREAT!!
Second command "rename dir1 dir2. " This gives me a return code of 256. The error is "The process cannot access the file because it is being used by another process". NOT GREAT!!!

BTW, I have a sleep of 3 seconds between commands.


Thanks in advance.

gheim
Oct 12 '07 #1
4 8644
numberwhun
3,509 Expert Mod 2GB
I am trying to make several system calls via Perl on a Windows box.

First command "rmdir ....". This gives me return code of 0. GREAT!!
Second command "rename dir1 dir2. " This gives me a return code of 256. The error is "The process cannot access the file because it is being used by another process". NOT GREAT!!!

BTW, I have a sleep of 3 seconds between commands.


Thanks in advance.

gheim
I would make sure that nothing else on the system is using the directory you are working on. In fact, are you out of that directory?

Regards,

Jeff
Oct 12 '07 #2
gheim
3
I would make sure that nothing else on the system is using the directory you are working on. In fact, are you out of that directory?

Regards,

Jeff
Jeff,

There is nothing else accessing the directory. I have shut down my editor and windows explorer. I do have a couple of dos windows open, but both of them are accessing different direcories.

gheim
Oct 12 '07 #3
numberwhun
3,509 Expert Mod 2GB
Jeff,

There is nothing else accessing the directory. I have shut down my editor and windows explorer. I do have a couple of dos windows open, but both of them are accessing different direcories.

gheim
Can you possibly post your code up here (enclosed in the proper [code] [/code] tags so that we can see what is going on?

Regards,

Jeff
Oct 12 '07 #4
gheim
3
Can you possibly post your code up here (enclosed in the proper tags so that we can see what is going on?

Regards,

Jeff
All,

Here is the overview of code:

We have two types of "MOVES" Full and Inc

Inc moves
- make sure all the directories exist
- move all files from droppoint to current

Full
- make sure all the directories exist
- remove the previous directory
- rename the current directory to previous
- make a new directory called current
- move the files from droppoint to current

Actual code:

Expand|Select|Wrap|Line Numbers
  1. sub system_call {
  2.     ($lcl_cmd, $junk) = @_;
  3.     local $function_name = "system_call";
  4.     logmsg( $function_name, "Doing system call $lcl_cmd" ); 
  5.     print "\nDoing system call :$lcl_cmd:\n";
  6.     local $rc = system( $lcl_cmd );
  7.     logmsg( $function_name, "The return code is ->$rc<-" ); 
  8.     print "\nrc is :$rc:\n";
  9.     return $rc; 
  10. } # end system_call subroutine
  11.  
  12. $rootloc="c:\\Logs\\";
  13. $droppoint="droppoint";
  14. $currentdir="current";
  15. $previousdir="previous";
  16.  
  17. @inc_cmds = (
  18.      "move $rootloc$droppoint\*\.\* $rootloc$currentdir"
  19. );
  20.  
  21. @full_cmds = (
  22.      "rmdir \/S \/Q $rootloc$previousdir" 
  23.     ,"rename $rootloc$currentdir $previousdir" 
  24.     ,"mkdir $rootloc$currentdir"
  25.     ,@inc_cmds
  26. );
  27.  
  28. #
  29. # check to make sure the three directories exist
  30. #
  31. $dir_name = $rootloc . $previousdir;
  32. logmsg( $functionname, "Checking for $dir_name." ); 
  33. opendir(DIRANDLE, $dir_name) || die "Can not open the directory :$dir_name:\n";
  34. close(DIRHANDLE);
  35.  
  36. $dir_name = $rootloc . $currentdir;
  37. logmsg( $functionname, "Checking for $dir_name." ); 
  38. opendir(DIRANDLE, $dir_name) || die "Can not open the directory :$dir_name:\n";
  39. close(DIRHANDLE);
  40.  
  41. $dir_name = $rootloc . $droppoint;
  42. logmsg( $functionname, "Checking for $dir_name." ); 
  43. opendir(DIRHANDLE, $dir_name) || die "Can not open the directory :$dir_name:\n";
  44. close(DIRHANDLE);
  45.  
  46. $sleep_sec = 10;
  47. logmsg( $functionname, "Sleeping for $sleep_sec seconds." ); 
  48. sleep( $sleep_sec );
  49.  
  50. if ( $move_type eq "F" ) {
  51.     @cmd_list = @full_cmds;
  52. } else {
  53.     @cmd_list = @inc_cmds;
  54. }
  55.  
  56.  
  57. foreach $cmd (@cmd_list) {
  58.     print "\ncmd is $cmd.\n";
  59.     $rc = system_call( $cmd );
  60.     if ( $rc != 0 ) {
  61.         exit( -1 );
  62.     } #end $rc check
  63.     $sleep_sec = 10;
  64.     logmsg( $functionname, "Sleeping for $sleep_sec seconds." ); 
  65.     sleep( $sleep_sec );
  66. } #end foreach loop
  67.  
THANKS!!!
Oct 12 '07 #5

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

Similar topics

1
by: Bob Helber | last post by:
I've got a perl script with a system command, within a for loop, that calls a FORTRAN program. For one of the iterations of the for loop the FORTRAN program quits with an error due to bad input. ...
7
by: AznCollegeGuy | last post by:
Hello, Im trying to invoke a simple perl script with in my visual c++ gui program to with c++'s system call feature: when i call: system("dir"); it works
2
by: Mark Cummings | last post by:
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...
1
by: qilin | last post by:
I have perl program which use system() to call another c program meanwhile the c program also use system() to execute a linux command line ....but not sure why it doesn't work. yes, the perl...
3
by: soniamadtha | last post by:
Hello everyone i have the following script (extract.pl) #!/usr/bin/perl # Purpose : This Program is used to extract only the stocklist from the input string #use warnings; scalar @ARGV...
3
by: creativeinspiration | last post by:
Hey guys. I am trying to implement a system call in linux kernel. I usually use ubutntu, but this I am doing on Fedora. I am using kernel 2.6. Here is what I did: 1. Added a line to...
5
by: b0dhi | last post by:
I'm a newbie with Perl. I'm trying to make a system call to move some files to another directory, but the directory is based on a variable that I've created. Here is a snippet of my code: ...
2
by: Liachta | last post by:
Hi I have a script called test.pl which calls another script using system The problem is in test.pl I want to call system("stockroom.pl?stkid=23&pn=17Z78&sn=1234567890") But this does...
1
by: houh | last post by:
I have a java app that generates openoffice docs. When I run the java app in a shell script, as: export JAVA_HOME=/opt/corp/projects/metrics/Java/jdk1.5.0_07/bin/java export...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.