469,311 Members | 2,482 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,311 developers. It's quick & easy.

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 8477
numberwhun
3,503 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,503 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

Post your reply

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

Similar topics

1 post views Thread by Bob Helber | last post: by
7 posts views Thread by AznCollegeGuy | last post: by
1 post views Thread by qilin | last post: by
3 posts views Thread by creativeinspiration | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.