duplicate argument 0

R

Ross

hi everybody,
when i try to obtain the file name by setting:

$filename = $ARGV[0];

i found $ARGV[0] actually contains a duplicate filename, e.g.


/var/www/A11NRXXX.DIF//var/www/A11NRXXX.DIF

this problem only occurs (i.e. it works normally by directly typing abc.pl
in shell) when i use a shell script as:

#!/bin/sh

for F in `/bin/ls $1`;do
/usr/bin/perl /var/www/abc.pl $1/$F
done

exit 0;


any idea please?
 
P

Paul Lalli

Ross said:
hi everybody,
when i try to obtain the file name by setting:

$filename = $ARGV[0];

i found $ARGV[0] actually contains a duplicate filename, e.g.


/var/www/A11NRXXX.DIF//var/www/A11NRXXX.DIF

Then that's what you passed to the perl script.
this problem only occurs (i.e. it works normally by directly typing abc.pl
in shell) when i use a shell script as:

#!/bin/sh

for F in `/bin/ls $1`;do
/usr/bin/perl /var/www/abc.pl $1/$F
done

exit 0;

Your question has nothing to do with Perl. Your question would be the
same regardless of the language in which the 'abc' script was written.
Your question is about how to correctly pass parameters from a shell
script.

Your script is taking it's first argument, and performing an `ls` on
it. It then apparently makes an assumption that this argument was a
directory name. If, however, your script is called with a filename,
such as '/var/www/A11NRXXX.DIF', then `ls` will return just that one
filename as well. Therefore, you're contactenating the filename, a
slash, and that filename again.

You need to rethink your shell script's algorithm.

Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top