Perl is often used for system configuration and management automation on open platforms, but it can also be applied flexibly on host systems. This article describes the three Perl modules associated with z/Os on CPAN, Net::ftp, Mvs::jesftp, and Net::Telnet, and explains their usage and considerations in conjunction with examples. Using these modules will help improve the productivity of z/OS system administrators and testers.
1 Introduction
In daily work, different tools are often used to interact between PCs and z/OS systems. We can upload or download various datasets using FTP. The host's FTP server also provides the ability to interact with Jes [1], we can directly use FTP on the PC side to submit JCL jobs to the host run, and the output of the job in spool received to the PC. In addition, the use of commonly used network connectivity tools (Rlogin/ssh/telnet) can interact with z/OS UNIX terminals [2], enabling remote execution of UNIX or TSO commands.
Perl is a scripting language with powerful text processing capabilities and flexible grammatical forms. At the same time, Perl is also an important system management tool on the open platform. In addition, Perl's comprehensive repository Cpan[4] is particularly rich in resources, providing tens of thousands of modules, involving various aspects of system management [5]. These modules have not only become a practical tool for system administrators, they also bring together their practical experience. This article will combine three CPAN modules to describe how to use Perl to accomplish common interactions between PCs and hosts.
2 using the Net::ftp module to download data
NET::FTP[6] is a core module that is released along with the Perl language. This module implements a simple FTP client that encapsulates a common interface for RFC959 (FILE TRANSFER PROTOCOL).
The use of the NET::FTP main interface is as follows [2]:
Use net::ftp;
$ftp = Net::ftp->new ("ftp.host.com") or die "Can ' t connect: $@\n";
$ftp->login ($username, $password) or die "couldn ' t login\n";
$ftp->CWD ($directory) or die "couldn ' t change directory\n";
$ftp->get ($filename) or die "couldn ' t get $filename \ n";
$ftp->put ($filename) or die "couldn ' t put $filename \ n";
Next, we'll explain how to use net::ftp to download and upload different types of data from the Host: Unix files, Ps,pds types of datasets.
2.1 Download upload Unix files
The USS (UNIX system Service) provided by the z/OS systems [2] meets the POSIX standard and provides a tree-file structure. We can simply call the Get interface to download the UNIX files in the USS System. For example, to download a log file from USS Failures.log, which is located in the directory/user/log, the sample code is as follows:
$pathname = "/user/log";
$logfile = "Failures.log";
$ftp = Net::ftp->new ("ftp.host.com", # FTP service-side address
Timeout => 30, # Wait a few seconds before dropping the connection
Debug => 1) # will output all commands to standard error
$ftp->login ($username, $password);
$ftp->ascii (); # ASCII mode transfer, CRLF will be automatically converted
$ftp->CWD ($pathname);
$ftp->get ($logfile);
$ftp->close ();