1753826 Members
8731 Online
108805 Solutions
New Discussion юеВ

Executing a Perl Command

 
Pando
Regular Advisor

Executing a Perl Command

I want to ask how can i execute or call dos2ux or rm command inside perl?

Herewith is my part of the script:

datapath="/test/parset/data_files/finaltest/Temp"
npath="/temp/SAMPLE"
ExePath="/usr/bin"
perl="/opt/perl/bin"
cd $datapath
ls -l *.TDF |awk '{print $9}' |while read FILE
do
perl -e '$PerlVar=$ENV{Var};$PerlVar=~ m/^[0-9][0-9]*[\.[0-9][0-9]*]{0,1}$/g;if (pos($PerlVar)) {exec("$ExePath/dos2ux $FILE > $npath/$FILE")} else {exec "$ExePath/rm $FILE"}'
done

When I execute it, it displays an error:

sh: /: Cannot create the specified file.
sh: /: Cannot create the specified file.

Maximum point for all correct replies.
3 REPLIES 3
c_51
Trusted Contributor

Re: Executing a Perl Command

might not be the reason, but
perl="/opt/perl/bin" then
perl -e ....

maybe your not using the version of perl you think you are.

you might check your quoting, double quotes inside of single quotes.
Pando
Regular Advisor

Re: Executing a Perl Command

Hi c,

I think the problem lies in this area:

{exec("$ExePath/dos2ux $FILE > $npath/$FILE")}

I dont know if i use the right command (system or exec) to execute the dos2ux command.

Pando
Regular Advisor

Re: Executing a Perl Command

I found the solution. Thanks!
Am very new to perl and through searching in this forum found other solutions in perl "system" command by the other in this forum!