LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Help with the perl Script? (https://www.linuxquestions.org/questions/programming-9/help-with-the-perl-script-749323/)

your_shadow03 08-21-2009 10:58 AM

Help with the perl Script?
 
I have downloaded a perl Script which will allow a user to login into chat Room session through IRC Port 6667.But What I need is I want 1000 users to login with incremental name like CGI123,CGI124 etc.,
Here is the script:

Code:

#!/usr/local/bin/perl -w
# irc.pl
# A simple IRC robot.
# Usage: perl irc.pl

use strict;

# We will use a raw socket to connect to the IRC server.
use IO::Socket;

# The server to connect to and our details.
my $server = "10.14.236.70";
my $nick = "simple_bbot";
my $login = "simple_bbot";

# The channel which the bot will join.
my $channel = "#Room1";

# Connect to the IRC server.
my $sock = new IO::Socket::INET(PeerAddr => $server,
                                PeerPort => 6667,
                                Proto => 'tcp') or
                                    die "Can't connect\n";

# Log on to the server.
print $sock "NICK $nick\r\n";
print $sock "USER $login 8 * :Perl IRC Hacks Robot\r\n";

# Read lines from the server until it tells us we have connected.
while (my $input = <$sock>) {
    # Check the numerical responses from the server.
    if ($input =~ /004/) {
        # We are now logged in.
    last;
    }
    elsif ($input =~ /433/) {
        die "Nickname is already in use.";
    }
}

# Join the channel.
print $sock "JOIN $channel\r\n";

# Keep reading lines from the server.
while (my $input = <$sock>) {
    chop $input;
    if ($input =~ /^PING(.*)$/i) {
        # We must respond to PINGs to avoid being disconnected.
        print $sock "PONG $1\r\n";
    }
    else {
        # Print the raw line received by the bot.
        print "$input\n";
    }
}

I am in verse to test Load on the Server by sending the messages repeatedly.
[/code]

Sergei Steshenko 08-21-2009 12:26 PM

Quote:

Originally Posted by your_shadow03 (Post 3652558)
I have downloaded a perl Script which will allow a user to login into chat Room session through IRC Port 6667.But What I need is I want 1000 users to login with incremental name like CGI123,CGI124 etc.,
Here is the script:

Code:

#!/usr/local/bin/perl -w
# irc.pl
# A simple IRC robot.
# Usage: perl irc.pl

use strict;

# We will use a raw socket to connect to the IRC server.
use IO::Socket;

# The server to connect to and our details.
my $server = "10.14.236.70";
my $nick = "simple_bbot";
my $login = "simple_bbot";

# The channel which the bot will join.
my $channel = "#Room1";

# Connect to the IRC server.
my $sock = new IO::Socket::INET(PeerAddr => $server,
                                PeerPort => 6667,
                                Proto => 'tcp') or
                                    die "Can't connect\n";

# Log on to the server.
print $sock "NICK $nick\r\n";
print $sock "USER $login 8 * :Perl IRC Hacks Robot\r\n";

# Read lines from the server until it tells us we have connected.
while (my $input = <$sock>) {
    # Check the numerical responses from the server.
    if ($input =~ /004/) {
        # We are now logged in.
    last;
    }
    elsif ($input =~ /433/) {
        die "Nickname is already in use.";
    }
}

# Join the channel.
print $sock "JOIN $channel\r\n";

# Keep reading lines from the server.
while (my $input = <$sock>) {
    chop $input;
    if ($input =~ /^PING(.*)$/i) {
        # We must respond to PINGs to avoid being disconnected.
        print $sock "PONG $1\r\n";
    }
    else {
        # Print the raw line received by the bot.
        print "$input\n";
    }
}

I am in verse to test Load on the Server by sending the messages repeatedly.
[/code]

So, what is the current user name and what entity in the script holds it ?

your_shadow03 08-21-2009 01:04 PM

simple_bbot is the nickname which gets added to the chat with channel #Room1.

Sergei Steshenko 08-21-2009 01:27 PM

Quote:

Originally Posted by your_shadow03 (Post 3652704)
simple_bbot is the nickname which gets added to the chat with channel #Room1.

You didn't answer the part of the question about variable name.

your_shadow03 08-21-2009 01:43 PM

I am new to perl. What I need is the script should login to chat server and add to the channel #Room1 and keep adding as many users as it can.

Sergei Steshenko 08-21-2009 03:09 PM

Quote:

Originally Posted by your_shadow03 (Post 3652752)
I am new to perl. What I need is the script should login to chat server and add to the channel #Room1 and keep adding as many users as it can.

So, you do not understand a single line in the script, you are not going to learn Perl and you want us to do your job ?


All times are GMT -5. The time now is 07:59 AM.