LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 02-02-2007, 12:15 AM   #1
icetomyst
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:

Code:
#!/usr/bin/perl -w

        use Net::OSCAR qw(:standard);


        $oscar = Net::OSCAR->new();
        $oscar->set_callback_im_in(\&im_in);
        $oscar->signon('USERNAME', 'PASSWORD');
        while(1) {
    $oscar->do_one_loop();
$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');

  exit();
        }
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 12:39 AM.
 
Old 02-02-2007, 01:25 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,226

Rep: Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022
Exactly what error do you get?
try
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, 02:53 AM   #3
icetomyst
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:

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

$screenname = UNAME;
$password = PASS;

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

        while(1) {
                $oscar->do_one_loop();
  $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 05:57 AM.
 
Old 02-02-2007, 04:14 PM   #4
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Well, that
Code:
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.
 
  


Reply

Tags
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/auth.al) in QNX(sendmail uing perl script) kuttylinux Programming 1 09-20-2006 12:58 AM
Urgent Help: Perl FTP Script Using NET::FTP xboxter Programming 8 05-16-2005 06:57 PM
Perl Net Ping jholl Programming 0 12-07-2004 10:22 AM
Converting a Windows Perl script to a Linux Perl script. rubbercash Programming 2 07-19-2004 10:22 AM
Including methods from a perl script into another perl script gene_gEnie Programming 3 01-31-2002 05:03 AM


All times are GMT -5. The time now is 07:16 PM.

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