2007 said:
I need help in writing please
As others have already said - show us what you got already!
Also, if I use "print" within perl to the dump a executable command to
the monitor, will the process be executed and the perl will wait
before it throws the next one to screen?
You can always tell noobies as they seem to invent strange
terminologies! Print doesn't "dump" executable commands to monitor.
Print prints things. What you tell it to print. It's displayed on
stdout, which nowadays is rarely a monitor but a terminal emulator. The
process will be executed if and when you tell Perl to execute a process
- and not before. Oh, and Perl doesn't throw anything to a screen... not
at all!
Perhaps you meant this:
"If I use 'print' to print the executable command to stdout will the
process be executed?"
Well print doesn't execute processes. The system Perl function will
and/or commands in `` will execute external processes. Printing out the
contents of your command before executing it will not cause it not to be
executed. Instead do something like this. Let's say you were executing a
command stored in $cmd.
my $cmd = "CONV1 $filename";
my @output = `$cmd`;
my $status = $?;
die "Unable to execute $cmd" if $status != 0;
$cmd = "CONV2 $filename2";
@output = `$cmd`;
die "Unable to execute $cmd" if $status != 0;
Change this to:
my $cmd = "CONV1 $filename";
print "About to execute \"$cmd\"\n";
#my @output = `$cmd`;
#my $status = $?;
#die "Unable to execute $cmd" if $status != 0;
print "About to execute \"$cmd\"\n";
#$cmd = "CONV2 $filename2";
#@output = `$cmd`;
#die "Unable to execute $cmd" if $status != 0;
So here I'm just printing out what $cmd contains. Note I commented out
the actual execution of the commands on the assumption that you didn't
want to actually execute them unless you saw that they looked OK.
Actually I would do this in Perl's debugger instead stopping at the
statement that was about to execute the $cmd and display it's contents
and only stepping forward if it were correct.