Register a domain and help support LQ
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-02-2007, 01:15 AM   #1
LQ Newbie
Registered: Jun 2006
Distribution: FC5
Posts: 14

Rep: Reputation: 0
NET::OSCAR perl script

first off i must say that I have never used anything like net::oscar or net::aim before....what im trying to do is write a small perl script that will login to AIM via net::oscar send an IM to a a couple people, then logout....this script will be invoked by a command on a game server.

Now, I managed to get the game server to run the script, but I cant seem to get Net::OSCAR to login and send the message...heres what i have:

#!/usr/bin/perl -w

        use Net::OSCAR qw(:standard);

        $oscar = Net::OSCAR->new();
        $oscar->signon('USERNAME', 'PASSWORD');
        while(1) {
$oscar->send_im('PERSON#1', 'test message test message');
$oscar->send_im('PERSON#2', 'test message test message');
$oscar->send_im('PERSON#3', 'test message test message');

I know i have to be doing something wrong, but what it is is beyond me. In all honesty the script would work better with my gameserver if it was shell, but that is beyond me as well.
I also have NET::AIM installed and would work just fine for what I need, if someone reading this is more familiar with that.
If anyone can be of any assistance I would appreciate it very much. Thanks in advance.

Last edited by icetomyst; 02-02-2007 at 01:39 AM.
Old 02-02-2007, 02:25 AM   #2
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.7, Centos 5.10
Posts: 16,912

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Exactly what error do you get?
use strict;
at the top after the use cmd.
Also, looks like you are calling a sub im_in() that isn't defined.
Old 02-02-2007, 03:53 AM   #3
LQ Newbie
Registered: Jun 2006
Distribution: FC5
Posts: 14

Original Poster
Rep: Reputation: 0
thanks for replying.

removed im_in and added use strict and added my before defining $oscar...still doesn't work, it never gave me any errors, just didnt work altogether.
so i decided to start over and came up with this:

#!/usr/bin/perl -w
use Net::OSCAR qw(:standard);

$screenname = UNAME;
$password = PASS;

        $oscar = Net::OSCAR->new();
        $oscar->signon($screenname, $password);

        while(1) {
  $oscar->send_im(PERSON1, 'hello');
Now that actually signed on and sent the message, only problem is it sends the message repeatedly and never stops and never signs off and it will crash if the person is not logged on, i tried adding $oscar->signoff; after send_im(PERSON1...); but that caused it to not be able to login at all...tried with and without strict...I added exit(); but then it wouldnt login at all. I know its repeating because it's in a while loop, but im not sure of another way to do it

Last edited by icetomyst; 02-02-2007 at 06:57 AM.
Old 02-02-2007, 05:14 PM   #4
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Well, that
while (1) {...}
is an explicitly infinite loop, so it makes sense that it never stops sending. What was your intention when you coded that while loop? It looks like in normal use of Net::OSCAR, you have to repeatedly call do_one_loop() to let it do its thing. I don't know this module, but 'perldoc Net::OSCAR' should provide some documentation.


perl, shell

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Authentication(auto/Net/SMTP/ in QNX(sendmail uing perl script) kuttylinux Programming 1 09-20-2006 01:58 AM
Urgent Help: Perl FTP Script Using NET::FTP xboxter Programming 8 05-16-2005 07:57 PM
Perl Net Ping jholl Programming 0 12-07-2004 11:22 AM
Converting a Windows Perl script to a Linux Perl script. rubbercash Programming 2 07-19-2004 11:22 AM
Including methods from a perl script into another perl script gene_gEnie Programming 3 01-31-2002 06:03 AM

All times are GMT -5. The time now is 09:26 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration