Dear Experts, I have been testing a simple portion of a script that is supposed to become part of something else and suddenly run into a problem: after I delete the Vmware Workstation snapshot using system() I get Bad file descriptor message. But the snaphot itself is successfully deleted! And the same command from the command prompt works all right. Here is my code:
#!/usr/bin/perl use Time::HiRes; use File::Path; use warnings; use strict; $|=1; sub spin { my ($arg) = @_; for (my $x = 0; $x <= $arg; ++$x) { foreach (("-", "\\", "|", "/")) { print $_; Time::HiRes::sleep (0.1); print "\b"; } } #print " \n"; } my $j = 0; my $base = "C:/Users/User/Documents/Virtua~1/"; print "Enter VM name: "; my $vm = <STDIN>; chomp ($vm); print "Enter Snapshot to be deleted: "; my $snapshot = <STDIN>; chomp ($snapshot); my $vmware_dir = "C:/Progra~2/Vmware/VMware~1/"; my $command = "$vmware_dir" . "vmrun -T ws deleteSnapshot " . "$base" +. "$vm" . "/" . "$vm" . ".vmx " . "$snapshot"; if ( (my $pid = fork() ) == 0) { do { sleep 0.5; spin($j) } while 1; } else { print "Deleting snapshot..."; system ("$command") or die "Operation failed: $!\n"; kill 9, $pid; waitpid $pid, 0; } print "\bDone!\n"; # Never gets here!
And this is what I get in the end:
Deleting snapshot...\Operation failed: Bad file descriptorAs I said, the snapshot gets deleted, but there is an error message and the background spinning never ends.
Thank you in advance!
In reply to Bad file descriptor after vmran command using system() by Ingvar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |