Matthew Roessner
asked on
iSeries PERL Scripts
I would like to start to utilize PERL to do some scripting on the iSeries. I was wondering if anyone knew how I could get started with this. I read somewhere that you should be able to go to the PASE environment (CALL QP2TERM) and run a command like:
`system wrkactjob` (using backticks .....upper left hand key)
When I attempt to run this - I get the following error:
QOpenSys/usr/bin/-sh: 5770SS1: not found
Wondering if there is some setup or configuration that needs done.
I am running V7R1...
Thanks!
`system wrkactjob` (using backticks .....upper left hand key)
When I attempt to run this - I get the following error:
QOpenSys/usr/bin/-sh: 5770SS1: not found
Wondering if there is some setup or configuration that needs done.
I am running V7R1...
Thanks!
----> CALL QP2TERM
> system wrkactjob
https://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/rzalf/rzalfpasesystem.htm
Note that screen IO is vastly different in PASE than in the native OS. Commands run in batch, and you'll receive OUTPUT(*PRINT) type output that has been captured and redirected to the screen.
You'll probably need to install Perl:
http://www-03.ibm.com/systems/power/software/i/db2/support/tips/qshellperl.html
> system wrkactjob
https://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/rzalf/rzalfpasesystem.htm
Note that screen IO is vastly different in PASE than in the native OS. Commands run in batch, and you'll receive OUTPUT(*PRINT) type output that has been captured and redirected to the screen.
You'll probably need to install Perl:
http://www-03.ibm.com/systems/power/software/i/db2/support/tips/qshellperl.html
ASKER
I was hoping to be able to create a PERL script and then execute that script. The "script" that I was trying to create - purely for educational purposes to start - is below:
DSPPIGS
<begin code>
#!/QOpensys/QIBM/ProdData/ DeveloperT ools/perl/ bin/perl
#File dsppigs created by ROESSNER
if ($ARGV[0] eq '-h') {
print "Usage: dsppigs [-h]\n";
print "This script runs the WRKACTJOB command, parses the output,
sorts by total CPU use. The top 12 CPU users are displayed to
standard out\n";
exit;
}
printf "\n\ndsppigs - Running WRKACTJOB...\n";
printf "CPU - Job\n";
@out = `system wrkactjob`;
# For each line of the WRKACTJOB output
foreach $outline (@out) {
($job,$user,$number,$typ,$ pool,$pty, $cpu,$rest ) = split(' ',$outline);
# Weed out Title info from @out
if($cpu eq "Jobs" | $cpu eq "CPU" | $cpu eq "." | $cpu eq "")
{next};
# Generate a Hash of each job with total CPU as key
$outhash{$cpu) = join("/",$number,$user,$jo b);
}
# Sort the hash by cpu usages
@key = sort {$a <=> $b}(keys %outhash);
#Print out the top 12 offenders
for ($i=$key-12; $i < $#key; $i++) {
printf "$key[$i] = #outhash($key[$i]}\n";
exit;
<end code>
I was then hoping to run this from a command line:
call qp2shell '/home/yourid/bin/dsppigs'
When I do this, I get the following error:
PASE for i program not found or in use. Path name is /home/yourid/bin/dsppigs
I was only trying to do the 'system wrkactjob' - because it was part of the script and I was trying to see if that was related to why the "script" wasn't working.
I have never ran anything with PERL before - so wasn't sure if I needed to set something up or if there was more to it. I did install 5799PTL which I was told I needed to do.
Any assistance to help me get started on this - that would be very much appreciated.
Thanks
DSPPIGS
<begin code>
#!/QOpensys/QIBM/ProdData/
#File dsppigs created by ROESSNER
if ($ARGV[0] eq '-h') {
print "Usage: dsppigs [-h]\n";
print "This script runs the WRKACTJOB command, parses the output,
sorts by total CPU use. The top 12 CPU users are displayed to
standard out\n";
exit;
}
printf "\n\ndsppigs - Running WRKACTJOB...\n";
printf "CPU - Job\n";
@out = `system wrkactjob`;
# For each line of the WRKACTJOB output
foreach $outline (@out) {
($job,$user,$number,$typ,$
# Weed out Title info from @out
if($cpu eq "Jobs" | $cpu eq "CPU" | $cpu eq "." | $cpu eq "")
{next};
# Generate a Hash of each job with total CPU as key
$outhash{$cpu) = join("/",$number,$user,$jo
}
# Sort the hash by cpu usages
@key = sort {$a <=> $b}(keys %outhash);
#Print out the top 12 offenders
for ($i=$key-12; $i < $#key; $i++) {
printf "$key[$i] = #outhash($key[$i]}\n";
exit;
<end code>
I was then hoping to run this from a command line:
call qp2shell '/home/yourid/bin/dsppigs'
When I do this, I get the following error:
PASE for i program not found or in use. Path name is /home/yourid/bin/dsppigs
I was only trying to do the 'system wrkactjob' - because it was part of the script and I was trying to see if that was related to why the "script" wasn't working.
I have never ran anything with PERL before - so wasn't sure if I needed to set something up or if there was more to it. I did install 5799PTL which I was told I needed to do.
Any assistance to help me get started on this - that would be very much appreciated.
Thanks
Using QP2SHELL is more complex than using QP2TERM. Try running it from QP2TERM. Also make sure you've set the script to be executable:
chmod 0777 path_to_your_script
chmod 0777 path_to_your_script
I have to ask...
Were you really using "/home/yourid/bin/dsppigs" for the path? Or did you actually use your /home directory? (Has your /home directory been created?)
Also, is the script named DSPPIGS? Or is it dsppigs? Or dsppigs.pl?
Were you really using "/home/yourid/bin/dsppigs"
Also, is the script named DSPPIGS? Or is it dsppigs? Or dsppigs.pl?
ASKER
I am using my own home directory (and it has been created).
I named the script dsppigs with no extention. I also tried to name it dsppigs.pl - but that didn't seem to make any difference.
I named the script dsppigs with no extention. I also tried to name it dsppigs.pl - but that didn't seem to make any difference.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
When you CALL QP2TERM, you start a secondary process in the PASE environment. PASE provides the capability to run AIX binaries on an IBM i system. QP2TERM is an interactive entry into. It's also possible to run batch (background) processes.
If Perl is needed, it would be installed for execution in PASE.