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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing FTP in a PERL Script within USS

Status
Not open for further replies.

tlearned

Programmer
Joined
Mar 6, 2007
Messages
4
Location
US
I am trying to submit an FTP within a PERL script within a USS (UNIX System Services) environment. Each time I run the script I get an error “Can't ftp to my IP: EDC5049I The specified file name could not be located.”

I am able to run FTP using the command line and also in a CSHELL script. I am positive the IP address is correct, because it is the IP address of the Mainframe I am trying to ftp to.

My code:

#libraries for FTP and time strings
#!/usr/SHRWARE/perl/bin -w
use diagnostics;
require 5.8.7;
use sigtrap;
use Net::FTP;
use Socket;
use POSIX qw(strftime);

# Set Variables
my $ftp = '';

# Set Local Directory
my $host = "168.230.158.11";
#y $host = "ibmdevl.fairisaac.com";
my $dir = "/u/fia/FIA1TPL/perl";
# Set up the file to get
my $file = "test_sub.jcl";

print "FTP = ";
print $ftp; print "\n";
print "Host = ";
print $host; print "\n";
print "Dir = ";
print $dir; print "\n";
print "File = ";
print $file; print "\n";


# Connect to Fair Isaac IBM
$ftp = Net::FTP->new("168.230.158.11",Timeout=>360) or $newerr=1;
push @ERRORS, "Can't ftp to $host: $!\n" if $newerr;
myerr() if $newerr;
print "Exec FTP =";
print "Connected.\n";


sub myerr {
print "Error: \n";
print @ERRORS;
exit 0;
}


My output is:

FTP = Host = 168.230.158.11
Dir = /u/fia/FIA1TPL/perl
File = test_sub.jcl
Error: Can't ftp to 168.230.158.11: EDC5049I The specified file name could not be located.

I would appreciate any help.


 
Where is $newerr initialized to zero?

 
It wasn't in my code, but I don't think this would have cause me the error of not being able to access the IP address.

Thanks
 
I see where cdlvj's coming from.

Try:

$newerr=0;
# Connect to Fair Isaac IBM
$ftp = Net::FTP->new("168.230.158.11",Timeout=>360) or $newerr=1;
push @ERRORS, "Can't ftp to $host: $!\n" if $newerr;
myerr() if $newerr;
print "Exec FTP =";
print "Connected.\n";

I'm not familiar with USS, what is it?


Mike

Hardware is that part of a computer which, when you remove electrical power, doesn't go away.

Want great answers to your Tek-Tips questions? Have a look at faq219-2884
 
I also saw where cdlvj was coming from. I did try to run after setting the newerr to 0, but I got the same error message.

USS is UNIX System Services. It is an UNIX environment on an IBM Mainframe. It is suppose to give me the ability to run different scripts/jobs and submit them in the other operating system. i.e. Submit a PERL script that will FTP some files to a TSO environment and then submit the job in TSO.
 
That's not good then, looks as if it might be something in the USS environment that is preventing the perl script running properly.

You say a C Shell script works - could you submit a csh script rather than Perl?

Mike

Hardware is that part of a computer which, when you remove electrical power, doesn't go away.

Want great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Thanks for your input Mike. Yes, we could use a csh, but my boss wants to use PERL. There are some other commands that we need to execute and PERL seems to be the language that is able to handle them.

I've got our IBM liasion working with IBM on the issue also.

Tom
 
Hello Tom,

As a last resort you might consider submitting a Perl script that creates and then executes a csh script which does your ftp job for you.
Code:
open(CSHSCRIPT,>'ftpjob.csh');
print CSHSCRIPT "commands that go in csh script\n";
print CSHSCRIPT "commands that go in csh script\n";
print CSHSCRIPT "commands that go in csh script\n";
print CSHSCRIPT "commands that go in csh script\n";
close CSHSCRIPT;
system('ftpjob.csh');
And yes I know, not elegant at all.

Mike

Hardware is that part of a computer which, when you remove electrical power, doesn't go away.

Want great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top