Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > duplicate argument 0

Reply
Thread Tools

duplicate argument 0

 
 
Ross
Guest
Posts: n/a
 
      10-07-2005
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?


 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      10-07-2005
Ross wrote:
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
function argument dependent on another function argument? Reckoner Python 11 01-19-2009 03:31 AM
Template argument as template argument nw C++ 0 04-14-2008 01:36 PM
Function pointers, variable argument functions calling other variable-argument functions (sort of) S?ren Gammelmark C Programming 1 01-07-2005 09:41 PM
How to pass variable argument list to another function w/ variable argument list? Ben Kial C Programming 1 11-15-2004 01:51 AM
defaulting argument to previous argument Bhushit Joshipura C++ 5 12-30-2003 03:21 PM



Advertisments