Newbie problem with perl and rsh

Z

zenshade

I'm trying to invoke a perl script with command line arguments on
server 2 from server 1. Here's what I do on S1:

$output=`rsh $host ./getdigits.pl $co_id $contact_id`;

Here's what I have on S2:

die "Wrong number of arguments." if $#ARGV!=1;
my ($co_id, $contact_id)=($ARGV[0],$ARGV[1]);

The script dies every time on S2 with "wrong args" message. Only one
argument is being passed to the script on S2. The second argument is
interpreted as a bad command on S1.

How do I work around this?
 
B

Brian McCauley

zenshade said:
Subject: Newbie problem with perl and rsh

I council you not to use the word "newbie" in subject lines - it tends
to predispose people against you. To see why see numerous previous
thread with "newbie" in the subject. Many the OPs in those threads
display behaviour with which you would do well not to associate yourself.

Similarly avoid the words "Perl" and "problem" in subject line in
comp.lang.perl.* as they are usually redundant. Clear and concise
subject lines are very important to the co-operative nature of Usenet.
Wasting space in them will be perceived as an uncooperative act and so
will also serve to predispose people against you.

Your problem has nothing to do with rsh. Had you tried replacing 'rsh'
with 'echo' you'd have found the problem persisted. This process is
known as "problem partitioning". It is an absolutely vital skill in
programming. If you think your problems lies elsewhere than it does
then you are unlikely to find a solution.

On the whole not a great subject line :)
I'm trying to invoke a perl script with command line arguments on
server 2 from server 1. Here's what I do on S1:

$output=`rsh $host ./getdigits.pl $co_id $contact_id`;

Here's what I have on S2:

die "Wrong number of arguments." if $#ARGV!=1;
my ($co_id, $contact_id)=($ARGV[0],$ARGV[1]);

The script dies every time on S2 with "wrong args" message. Only one
argument is being passed to the script on S2. The second argument is
interpreted as a bad command on S1.

How do I work around this?

At a guess I'd say remove the linefeed from the end of $co_id.

Most likely you have a chomp() missing in your program somewhere.
I can't say where because you didn't show us a minimal but complete
script. It is stongly recommened that you post a minimal but complete
script to illustrate your problem. This process alone will often solve
your problem or at least serve to verify your partitioning of the problem.

Pretty much all the advice I've given here (and much more besides) can
be found in the posting guidelines for this group. I stongly advised
you to take a look.
 
G

gnari

[good criticism of subject line snipped]
I'm trying to invoke a perl script with command line arguments on
server 2 from server 1. Here's what I do on S1:

$output=`rsh $host ./getdigits.pl $co_id $contact_id`;

Here's what I have on S2:

die "Wrong number of arguments." if $#ARGV!=1;
my ($co_id, $contact_id)=($ARGV[0],$ARGV[1]);

The script dies every time on S2 with "wrong args" message. Only one
argument is being passed to the script on S2. The second argument is
interpreted as a bad command on S1.

let me add to Brian's comments:
a) you show us a snippet with a error message "Wrong number of arguments."
and then you say that the script dies with "wrong args"
I spent some time trying to figure if you whether you were complaining
that the die was executed or not.

b) the error message and test for the die are very poor. always
flesh out the error messages so that they say something more
than the obvious 'something failed'. for example:
die "Wrong number of arguments ($#ARGV):["
.join('][',@ARGV).']' if if $#ARGV!=1;
this would have shown the actual number of arguments, and
what they were. the square brackets would have made it very clear
if the problem for example happens to be a linefeed in the arguments.

gnari
 
Z

zenshade

Brian McCauley said:
I council you not to use the word "newbie" in subject lines - it tends
to predispose people against you...
Your problem has nothing to do with rsh. Had you tried replacing 'rsh'
with 'echo' you'd have found the problem persisted. This process is
known as "problem partitioning". It is an absolutely vital skill in
programming. If you think your problems lies elsewhere than it does
then you are unlikely to find a solution.

Let N be the number of lines in your response. Subtract one. N - 1
is the number of unnecessary lines in your post.
At a guess I'd say remove the linefeed from the end of $co_id.

This would have been quite sufficient. Your points are well taken and
the line above much appreciated, but is it really necessary to strike
such a condescending, prejudicial, and one might even say arrogant
attitude?
Clear and concise
subject lines are very important to the co-operative nature of Usenet.
Wasting space in them will be perceived as an uncooperative act and so
will also serve to predispose people against you.

While I'm certainly in favor of giving a nod in the direction of
clarity and conciseness for the sake of general principles, there
comes a point where I'd much sooner just tell a great lot of people to
piss off than put up with their snobbery and finicky, nit-picky
notions of what and how Usenet is to be used. Not that you've actually
crossed that line or anything :). (Anyone feeling compelled to point
out the grammar errors in the previous sentences has most definitely
crossed that line. So piss off ;)

Seriously, though, thanks for mentioning the linefeed. That's exactly
the type of response I was looking for.
 
S

Sam Holden

Let N be the number of lines in your response. Subtract one. N - 1
is the number of unnecessary lines in your post.

Because good general advice isn't useful.
This would have been quite sufficient. Your points are well taken and
the line above much appreciated, but is it really necessary to strike
such a condescending, prejudicial, and one might even say arrogant
attitude?

You decided not to follow the posting guidelines and so on, and just
expect everyone to bow to you whims. How arrogant of us.

Anyway, you might want to find somewhere you haven't been killfiled
by most of the helpful people for your next demand.
 
A

Anno Siegel

zenshade said:
Let N be the number of lines in your response. Subtract one. N - 1
is the number of unnecessary lines in your post.

So you define as "unnecessary" what you don't want to hear? How arrogant
is that?

Anno
 
A

Abhinav

zenshade said:
Let N be the number of lines in your response. Subtract one. N - 1
is the number of unnecessary lines in your post.

If you have lurked around this group for even a day, you will find that the
person who replied to your post is one of the most helpful out here, and
AFAI am concerned, one of the veterans.

Hope that puts your view in the proper perspective.


Regards
 
T

Tad McClellan

zenshade said:
Let N be the number of lines in your response. Subtract one. N - 1
is the number of unnecessary lines in your post.


Actually, N is the number of unnecessary lines in the post.

It is not necessary that you get _any_ answers at all.

Your points are well taken and


You seem to have a strange definition of the phrase "well taken"...

comes a point where I'd much sooner just tell a great lot of people to
piss off than put up with their snobbery and finicky, nit-picky
notions of what and how Usenet is to be used.


So, you have lurked here for some time already, and know
what is expected here?

If so, then why did you not do what is expected?

Seriously, though, thanks for mentioning the linefeed. That's exactly
the type of response I was looking for.


The probability of getting answers to future Perl questions
has been greatly diminished by the content of your followup.

Hope it made you feel better.
 
Z

zenshade

Tad McClellan said:
Actually, N is the number of unnecessary lines in the post.

It is not necessary that you get _any_ answers at all.




You seem to have a strange definition of the phrase "well taken"...




So, you have lurked here for some time already, and know
what is expected here?

If so, then why did you not do what is expected?




The probability of getting answers to future Perl questions
has been greatly diminished by the content of your followup.

Hope it made you feel better.

My sincere apology if I have given offense. Having reread my post and
the responses, I realize what an ignorant, insensitive lout I have
appeared to be. That was not at all my intention. Of course I was
being lazy. And Brian McCauley was certainly justified in calling me
out on it.

I am but a toad, and do truly appreciate any crumbs of true wisdom
that may be tossed my way.

Humbly Yours,
zenshade
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top