Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Net::SCP::Expect - error handling routines

Status
Not open for further replies.

SkyHigh

Technical User
May 30, 2002
309
CA
Hi
I have finally written the following script which handles the scp successfully, but I cannot get it to print msgs, I need to add some error handling routines, and responses, like if connected and file transferred it should print this msg or else print the error mesgs - thanks for your help
Brenda

------[Script]-------
#/usr/local/bin/perl -w
use lib '/opt/pg/pgperl/lib/site_perl/5.6.1/';
use Net::SCP::Expect;

open STDERR, ">>script.log" or die $!;

$scpe = Net::SCP::Expect->new(host=>'solarisbox',user=>'solaris',password=>'solaris',auto_yes=>1,timeout_auto,verbose=>1);

$scpe->scp('script.txt','/opt/logs/scripts/');
if ($scpe == NULL) {
print STDERR "Could not connect to the host\n";
exit(9);
}else{
print STDERR "SCP to target was successful\n";
}
close STDERR;
exit;
------[Script]-------
 
Anyone familiar with this ? please help
thanks
Brenda
 
I don't know anything about 'scp' but I can ask a couple of questions.

1. in your example above, is 'script.log' and 'script.txt' two different files or is something misspelled?
2. is anything getting writen to the file?
3. can you print some of your variables to screen to see what's happening?

Just thinking out loud!

tgus

__________________________________________________________________
A father's calling is eternal, and its importance transcends time.
 
Hi

1. script.log is the file where I want msgs printed
and script.txt is the file to be scp'ed.

2. all errors and responses should be written to script.log

3. thats what I need your help for

tks
Brenda
 
can you try;

print $scpe;

# print this to the screen just before the next line

if ($scpe == NULL) {

what is the value of $scpe that is printed?

It could be dying before it gets this far.
Are you getting any errors? is it printing anything to your .log?

I'm not sure but you could try if ($scpe eq NULL) { # instead of ==

Maybe you can't check for NULL?

Again, I don't know anything about 'scp'.

Hope this helps!
tgus

____________________________________________________
A father's calling is eternal, and its importance transcends time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top