User Control Panel
Advertisements

HELP US, HELP YOU!

View Directory

 
Post new topic   Reply to topic    Bot Depot Forum Index -> General Programming Questions
View unanswered posts
Author Message
Cheater
Senior Member
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Tue Jun 14, 2005 5:42 pm    Post subject: View Directory Reply with quote

I'm using this code to view the files in a directory:

Code:
sub view {
   my ($self,$client,$msg,$listener) = @_;

#!/usr/bin/perl
opendir MYDIR, "/notes/$client";
@contents = grep !/^\.\.?$/. readdir MYDIR;
closedir MYDIR;
foreach $listitem ( @contents )
{
  print $listitem;
}
1;


I use Nexusbot, and it keeps saying that that is not a command. It is in my commands>client folder.
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Tue Jun 14, 2005 5:48 pm    Post subject: Re: View Directory Reply with quote

Cheater wrote:
I'm using this code to view the files in a directory:

Code:
sub view {
   my ($self,$client,$msg,$listener) = @_;

#!/usr/bin/perl
opendir MYDIR, "/notes/$client";
@contents = grep !/^\.\.?$/. readdir MYDIR;
closedir MYDIR;
foreach $listitem ( @contents )
{
  print $listitem;
}
1;


I use Nexusbot, and it keeps saying that that is not a command. It is in my commands>client folder.


First of all, that code has a few too many syntax errors. For one, there's no closing bracket on the subroutine. Also, "print" isn't going to do anything if it's a command, you'll need to return a reply, printing will just do stuff on the DOS window that nobody else will ever see.

And to get it to recognize it as a command, the filename has to have the same name as the subroutine (view.pl)
Back to top
darkmonkey
The Merovingian
The Merovingian


Joined: 18 Apr 2004
Posts: 2557
Location: London, England
Reputation: 39.3Reputation: 39.3Reputation: 39.3Reputation: 39.3
votes: 7

PostPosted: Tue Jun 14, 2005 6:54 pm    Post subject: Reply with quote

Gotta love your copy + pasting (#!/usr/bin/perl). Why not take a few minutes and learn perl?
_________________
~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Back to top
Cheater
Senior Member
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Wed Jun 15, 2005 12:10 am    Post subject: Reply with quote

If I could find a basic enough tutorial (that talked about perl in relation to bots) I would. All the tutorials I find are either too complex, or not what I need for a bot
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Wed Jun 15, 2005 3:24 am    Post subject: Reply with quote

Search Google for "Perl Tutorial" - http://www.google.com/search?q=Perl+tutorial

There's no tutorials for "Learning Perl in relation to bots" because it would be pointless. If you just learn Perl in general, you can apply it to bots, because bots may use all or none of what Perl is capable of. Things like working with files, directories, split, join, subroutines, return, arrays, scalars, hashes, hashrefs.... you name it, and it's probably useable in a bot in some way.

So, even if you have to stray away from bots for a while to test out some new Perl code you just learned, go ahead and do that, because after you have experience in Perl in general, you'll have the know-how to apply it to your bot.
Back to top
Cheater
Senior Member
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Wed Jun 15, 2005 12:17 pm    Post subject: Reply with quote

I'll give it a try. hopefully I can find one easy enough.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> General Programming Questions All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group