Script to do the following checks


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to do the following checks
# 1  
Old 10-23-2012
Script to do the following checks

Hi ,

I need a script for processing below scenario.

I have to check daily by doing ftp IP to check it is logging or not.
So i want this activity to be automated such that if login succesful i will get "FTP LOGIN SUCCESS" in a log file and if fails i want the error message in the same log file.

COuld you please help
# 2  
Old 10-23-2012
Calling something akin to the following from cron should work.

Code:
#!/usr/bin/perl

use strict;
use Net::FTP;
my $username="$ENV{USER}"; # or whoever the ftp account belongs to
my $password = "p455w0rd"; # Your actual password
my $error_string="FTP LOGIN SUCCESS";
my $ftp = Net::FTP->new("some.host.ip", Debug => 0)
             or  $error_string = "Cannot connect to some.host.name: $!";
$ftp->login($username, $password)
             or $error_string="Cannot login ", $ftp->message;
$ftp->quit;
print $log_file scalar (localtime(time)) ,. "$error_string\n";
exit 1;

This User Gave Thanks to Skrynesaver For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with delaying script and implementing checks before completion

Hello everyone, I was wondering if any of you could help me with this. I am an absolute beginner and don't know how to program, but I can follow a tutorial and tweak code sometimes. My understanding of programing is limitted to what for and while loops do, and how if then else logic works. That... (2 Replies)
Discussion started by: tomeurp
2 Replies

2. Shell Programming and Scripting

[Help] Bash script that runs in the background and checks for mails...

Hello! I have got a homework. The bash script runs in the background and checks the user's mailbox and when the user gets a new mail a popup window appears with some text and information about the sender (from who and when).I have no idea how to start, any help would be appreciated! Thank you:) (1 Reply)
Discussion started by: capo2ndfret
1 Replies

3. Shell Programming and Scripting

Need to write a script that checks whether files are moving out of a directory.

I have a directory that has files going into it and moving out on a regular basis. The normal state of the directory would be to be empty. I need to write a script that will check to see if files are Not moving out of the directory. Any help would be most welcome. (4 Replies)
Discussion started by: RoBKoS
4 Replies

4. Shell Programming and Scripting

Script function which checks if itself is already running

Hi All, I have a cron job set up which is set to run every 10 seconds. What I need to do is have the script do a check to see if it is already running such that if it is running it wont fire up additional instances and processes according to its normal process. For example if I have a script... (4 Replies)
Discussion started by: landossa
4 Replies

5. Shell Programming and Scripting

Script to performs checks

Hi , I need a script which performs below activity I have one file named "testfile" in 9 different directories with same name. I want to perform below action with each testfile of each directory. if ; then mv listfiles listfiles_`date +%b%y` else echo No Such files fi ... (4 Replies)
Discussion started by: sv0081493
4 Replies

6. Shell Programming and Scripting

[Bash] MD5 Checks with Script.

Hi. I'm triyng to make a Bash Script that checks (recursively) the MD5 from all the files in a certain directory and compare them against some other check that should be already done and saved in a file. I've reached to the point where i have the MD5 from the file and the MD5 that the script... (1 Reply)
Discussion started by: BiFo
1 Replies

7. Shell Programming and Scripting

Perl script that checks against Future time

Ok, so this may be an unusual request. But I have a certificate that expires sometime in may of 2011. Now, i have to monitor this certificate and alert when the current time is within 30 days of may 20, 2011. #!/usr/bin/perl # use Time::Local; # $sec=59; $min=59; $hours=23; $day=31;... (3 Replies)
Discussion started by: SkySmart
3 Replies

8. Shell Programming and Scripting

Script to perform record format checks

Hi All, I have a requirement to perform the following checks. Input file is a "|" delimited file and looks like this. A|c1|c2|c3|.... B|G1|G2|G3.... C|H1|H2|H3... A|c4|c5|c6|.... B|G4|G5|G6.... C|H4|H5|H6... Now the check is to see if all the "A" records have a corresponding B... (7 Replies)
Discussion started by: gsjdrr
7 Replies

9. Shell Programming and Scripting

Want to make a script that checks connection protocol

Hello all, I currently connect to several servers multiple times a day. Most of the time I connect via SSH through the terminal emulator poderosa (my personal favorite), but sometimes I connect via telnet through xstart because I need it to export a GUI. What I want to do is add something to... (3 Replies)
Discussion started by: DeCoTwc
3 Replies

10. Shell Programming and Scripting

Script that checks for previous instances running

Hello, I'm trying to write a script that checks for previous instances of the same script which may still be running (this script is scheduled to run every 30 minutes). I want to somehow use the pid from each instance to make sure the previous one isn't running before continuing with my... (5 Replies)
Discussion started by: bd_joy
5 Replies
Login or Register to Ask a Question