Saurabh Singhvi
Mar 4 2005, 12:49 PM
#!/usr/bin/perl -w
use strict;
opendir(DIR,".") or die "Couldn't open $!";
our @names = readdir(DIR) or die "Couldn't open $!";
closedir(DIR);
foreach my $name (@names){
if ($name =~ /avi$/) {
my $var = $name;
$var =~ s/s/\ /;
$var =~ s/[/\[/;
$var =~ s/]/\]/;
system("mencoder $var -ovc lavc -oac copy -o $var.avi");
}
}
in this script i am having a big problem.........the script just ends
after the system command and returns to the shell..........what could
be the reason???
some1 plz help me
thnx in adv
Saurabh
Vladimir D Belousov
Mar 4 2005, 03:25 PM
First, your regext could be
$var =~ s/[s[]]/\$1/g;
Next, you should use two arguments style "system" calls:
system("/usr/local/bin/programm", args);
Third, you have to analyze a return code of a "system" command:
my $status = system(...);
print "Error [errno = $status]n" if($status);
Saurabh Singhvi wrote:
QUOTE |
#!/usr/bin/perl -w use strict;
opendir(DIR,".") or die "Couldn't open $!"; our @names = readdir(DIR) or die "Couldn't open $!"; closedir(DIR);
foreach my $name (@names){ if ($name =~ /avi$/) { my $var = $name; $var =~ s/s/\ /; $var =~ s/[/\[/; $var =~ s/]/\]/; system("mencoder $var -ovc lavc -oac copy -o $var.avi"); } }
in this script i am having a big problem.........the script just ends after the system command and returns to the shell..........what could be the reason???
some1 plz help me
thnx in adv Saurabh
|
--
Vladimir D Belousov
HiTech solutions for business
http://businessreklama.ru
John W. Krahn
Mar 5 2005, 06:11 AM
Saurabh Singhvi wrote:
QUOTE |
#!/usr/bin/perl -w use strict;
opendir(DIR,".") or die "Couldn't open $!"; our @names = readdir(DIR) or die "Couldn't open $!"; closedir(DIR);
foreach my $name (@names){ if ($name =~ /avi$/) { my $var = $name; $var =~ s/s/\ /; $var =~ s/[/\[/; $var =~ s/]/\]/; system("mencoder $var -ovc lavc -oac copy -o $var.avi"); } }
in this script i am having a big problem.........the script just ends after the system command and returns to the shell..........what could be the reason???
|
This should work better:
#!/usr/bin/perl -w
use strict;
opendir DIR, '.' or die "Couldn't open '.' $!";
( my @names = readdir DIR ) or die "Couldn't read '.' $!";
closedir DIR;
foreach my $name ( @names ) {
next unless $name =~ /avi$/;
my $var = $name;
system( 'mencoder', qq("Q$varE"), '-ovc', 'lavc', '-oac', 'copy', '-o',
qq("Q$varE.avi") ) == 0
or die "system 'mencoder' failed: $?";
}
John
--
use Perl;
program
fulfillment
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.