Invoke Procedure Help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Invoke Procedure Help
# 1  
Old 11-10-2011
Invoke Procedure Help

Hello unix.com users,

I reached a dead end with a procedure.
My files:

x.pl
Code:
#!/usr/bin/perl

use Net::FTP;

my $host = $ARGV[0];
my $user = $ARGV[1];
my $pass = $ARGV[2] || "";
my $port = "21";

$ftp=Net::FTP->new("$host", Port=>"$port", Timeout => 5)
or die("couldn't connect to host:" . $host . " on port " . $port);

if($ftp->login("$user","$pass")) {
 print "Login found: $host $user $pass\n";
 open (MYFILE, '>>ftp.log');
 print MYFILE "$host $user $pass\n";
 close (MYFILE);
}

$ftp->close();

connect
Code:
cat $1 | while read LN; do
SRV=`echo $LN | awk '{print $1}'`
USR=`echo $LN | awk '{print $2}'`
PAS=`echo $LN | awk '{print $3}'`
perl x.pl $SRV $USR $PAS
done

Currently uses a single file in format "ip user password"
I want it to make to use a defined file with ip list (line-by-line) and a password file (in format "user/password" also line-by-line). The perl script to check every ip with every line in password file and to move to next after password checks are done.

Thanks in advance,
Galford D. Weller
# 2  
Old 11-11-2011
Try with this ..
Code:
for ip in $(cat ip_file)
do
        while read USR PAS
        do
                perl x.pl $ip $USR $PAS
        done < user_password_file
done

This User Gave Thanks to jayan_jay For This Post:
# 3  
Old 11-11-2011
Thank you. Works fine.

Any extra help to make the script multi-thread? I got an example:
Code:
CMD=`ps -eaf | grep -c smtp.php`
if [ "$CMD" -lt "10" ]; then
    perl x.pl ....
else
        sleep 15
fi
done

To insert this in the connect file... Of course needs a fix.

Also if gets timeout output to an ip. To move to the next in line.

Thanks,
Galford D. Weller

Moderator's Comments:
Mod Comment Please use code tags <- click the link!

Last edited by vbe; 11-12-2011 at 05:15 PM.. Reason: code tags also keep the formatting you done...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Wget invoke a button

Hi I have a certain URL(ABC TV Network - Shows, Episodes, Schedules & Programming - ABC.com) and I want to invoke a button (say abc) in it from BASH. How should I do it using wget? Any help! Thanks in advance (2 Replies)
Discussion started by: ankur328
2 Replies

2. Homework & Coursework Questions

Invoke an exe file!!

Hello, Thank you for reading my Thread. I am very very new to Perl / Shell Scripting here. I m assigned some tasks here. I have an exe file on our server. I have to navigate to the path and invoke the exe file. Can someone please guide me with that. Thanks you, Skaranth (1 Reply)
Discussion started by: skaranth
1 Replies

3. UNIX for Advanced & Expert Users

How to invoke an URL

Hi, I am trying to invoke an service using URL. I want to know how to call that url with nohup. nohup links "__http://Administrator:assword@ServName:8080/invoke/wm.server.admin/shutdown?bounce=no&option=force&timeout=0" & I am trying to run this command on unix command prompt, But in... (8 Replies)
Discussion started by: swap27
8 Replies

4. UNIX for Dummies Questions & Answers

How to invoke ESC+K

How to invoke ESC+K to get recent commands in Korn Shell. In some of the unix machine ESC+K is available and in some machines, it does not work. All of the machines that I work have Korn shell. (5 Replies)
Discussion started by: bobbygsk
5 Replies

5. UNIX for Advanced & Expert Users

OOM KIller INVOKE

Hi I have written a code that will exhaust the memory completely by allocating it and not freeing it. The OOM killer as expected in invoked and it killed a few high memory using processes and their childs. But after that, though the system is not getting hung, it is not printing any msgs in... (3 Replies)
Discussion started by: subratasaharia
3 Replies

6. Shell Programming and Scripting

invoke ksh in SunOS 5.7

Hi I have the following in .kshrc file set -o allexport HOSTNAME=$(uname -n) HISTSIZE=50 EDITOR=vi ENV=$HOME/.kshrc PATH=$HOME/bin:/usr/bin:/usr/local:/etc/bin/:/bin:/usr/local/bin:. bind =complete set +o allexport clear and I have the following in .profile umask 077... (2 Replies)
Discussion started by: muru
2 Replies

7. Shell Programming and Scripting

Invoke Terminal Without Profile

Hey, I need to open a terminal via a shell script, but i need it to not read any of the start up files. So far I was thinking something along the lines of this but it was unsuccessfull !#bin/sh /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal --noprofile any ideas on how to... (0 Replies)
Discussion started by: meskue
0 Replies

8. Shell Programming and Scripting

invoke same script twice

hey, can I invoke the same script twice simultaneously? I want both instances to run at the same time with different parameters. Thanks! (2 Replies)
Discussion started by: mpang_
2 Replies

9. Shell Programming and Scripting

how to invoke shell script

hi everybody, i learning unix now only.Can u pls guide me in invoking a shell script.Actually i need to know how to write the command for invoking the shell script.Suppose the shell file name is count , then how i will write the command. thanks (1 Reply)
Discussion started by: gopa_mani
1 Replies
Login or Register to Ask a Question