Except script error

R

ruud

I am rewriting my Except script from bash to Perl.
But i get an syntax error at the Send command.
Google is not helping me out here, so i hope for an answer here.

Here is a part of the script:

#!/usr/bin/perl -w
use Expect;
                                                                                                                             
$post = "post";
$quit = "quit";
                                                                                                                             
spawn telnet "news.nl-netwerken.com 119";
                                                                                                                             
expect {
        200}
                                                                                                                             
send "$post\r";                                                                                                                              
expect {
        340}

And here is the error:
syntax error at ./p line 12, near "send"
Execution of ./p aborted due to compilation errors.

What is wrong with this line ?
Thanks for your time.
 
N

Noel

ruud said:
I am rewriting my Except script from bash to Perl.
But i get an syntax error at the Send command.
Google is not helping me out here, so i hope for an answer here.

Here is a part of the script:

#!/usr/bin/perl -w
use Expect;

$post = "post";
$quit = "quit";

spawn telnet "news.nl-netwerken.com 119";

expect {
200}

send "$post\r";
expect {
340}

And here is the error:
syntax error at ./p line 12, near "send"
Execution of ./p aborted due to compilation errors.

What is wrong with this line ?
Thanks for your time.

# Always use...
use strict;
use warnings;
#... at the start of your code.

At the very least your ~expect~ commands seem to be missing the closing
semi-colon ~;~. Include these then try it.
 
R

ruud

Noel said:
# Always use...
use strict;
use warnings;
#... at the start of your code.

At the very least your ~expect~ commands seem to be missing the closing
semi-colon ~;~. Include these then try it.

I changed is a little bit, but still 1 error left:
Not enough arguments for send at ./p line 10, near ""post\n")"

Here is the new script:

#!/usr/bin/perl -w
use Expect;
use strict;
use warnings;
post ("post");
spawn telnet ("news.nl-netwerken.com 119");
expect ("200");
send ("post\n");
expect ("340");

Thanks for helping me out b.t.w.
 
M

Michele Dondi

#!/usr/bin/perl -w
use Expect;

expect {
        200}

send "$post\r"; [snip]
And here is the error:
syntax error at ./p line 12, near "send"
Execution of ./p aborted due to compilation errors.

What is wrong with this line ?
Thanks for your time.

Nothing, but you forgot something _before_ that line. Hint: ";"!


HTH,
Michele
 
N

Noel

ruud said:
I changed is a little bit, but still 1 error left:
Not enough arguments for send at ./p line 10, near ""post\n")"

Here is the new script:

#!/usr/bin/perl -w
use Expect;
use strict;
use warnings;
post ("post");
spawn telnet ("news.nl-netwerken.com 119");
expect ("200");
send ("post\n");
expect ("340");

Thanks for helping me out b.t.w.

'fraid I don't know this module's usage too well, but hopefully this link
will be of help...

http://search.cpan.org/~rgiersig/Expect-1.15/Expect.pod
 
R

ruud

Michele said:
Do a favour to yourself and C<use strict;> too. Also C<use warnings;>
is better than -w.

Hi Michele, can you look at my new script further in this threat ?
I think it is better but still no luck after 2 day's google :-(
I really apreciate your time and knowhow.
 
M

Michele Dondi

Hi Michele, can you look at my new script further in this threat ?
I think it is better but still no luck after 2 day's google :-(
I really apreciate your time and knowhow.

Sorry, but the first answer I gave to you had nothing to do
specifically with the module you're using. OTOH in another post you
wrote:

| I changed is a little bit, but still 1 error left:
| Not enough arguments for send at ./p line 10, near ""post\n")"

which seems to be the problem you have _now_. In that case, is that
Perl's send() or a function from Expect.pm? In the latter case you I
don't have any experience with it and you should read its
documentation by yourself. In the former

: perldoc -f send
: send SOCKET,MSG,FLAGS,TO
: send SOCKET,MSG,FLAGS

(I _suspect_ you may be thinking of using some function exported by
Expect.pm whereas you're really calling a Perl internal function with
the wrong number of arguments.)


HTH,
Michele
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top