183 lines
6.3 KiB
HTML
183 lines
6.3 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="reference" />
|
|
<meta name="DC.Title" content="Example: Using JobList to list job identification information" />
|
|
<meta name="abstract" content="" />
|
|
<meta name="description" content="" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="listjobs2" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>Example: Using JobList to list job identification information</title>
|
|
</head>
|
|
<body id="listjobs2"><a name="listjobs2"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example: Using JobList to list job identification information</h1>
|
|
<div><p></p>
|
|
<div class="section"><div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
|
|
example disclaimer</a> for important legal information.</div>
|
|
<pre>///////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// This program is an example of the Job support in the IBM Toolbox
|
|
// for Java. It lists job identification information for a specific
|
|
// user on the system.
|
|
//
|
|
// Command syntax:
|
|
// listJobs2 system userID password
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
import java.io.*;
|
|
import java.lang.*;
|
|
import java.util.*;
|
|
import com.ibm.as400.access.*;
|
|
|
|
public class listJobs2 extends Object
|
|
{
|
|
|
|
// Create an object in case we want to call
|
|
// any non-staic methods.
|
|
public static void main(String[] parameters)
|
|
{
|
|
listJobs2 me = new listJobs2();
|
|
me.Main(parameters);
|
|
|
|
System.exit(0);
|
|
}
|
|
|
|
|
|
|
|
void Main(String[] parameters)
|
|
{
|
|
|
|
// If a system was not specified, display help text and exit.
|
|
if (parameters.length == 0)
|
|
{
|
|
showHelp();
|
|
return;
|
|
}
|
|
|
|
// Assign the parameters to variables. The
|
|
// first parameter is assumed to be the system
|
|
// name the second is a userID and the third
|
|
// is a password.
|
|
String systemName = parameters[0];
|
|
String userID = null;
|
|
String password = null;
|
|
|
|
if (parameters.length > 1)
|
|
userID = parameters[1].toUpperCase();
|
|
|
|
if (parameters.length >= 2)
|
|
password = parameters[2].toUpperCase();
|
|
|
|
System.out.println(" ");
|
|
|
|
|
|
|
|
try
|
|
{
|
|
|
|
// Create an AS400 object using the system name
|
|
// specified by the user. Set the userid and
|
|
// password if specified by the user.
|
|
AS400 as400 = new AS400(parameters[0]);
|
|
|
|
if (userID != null)
|
|
as400.setUserId(userID);
|
|
|
|
if (password != null)
|
|
as400.setPassword(password);
|
|
|
|
|
|
|
|
System.out.println("retrieving list ... ");
|
|
|
|
|
|
// Create a jobList object. This object is used
|
|
// to retrieve the list of active jobs on the server.
|
|
JobList jobList = new JobList(as400);
|
|
|
|
|
|
// Get the list of active jobs.
|
|
Enumeration list = jobList.getJobs();
|
|
|
|
|
|
// For each job in the list ...
|
|
while (list.hasMoreElements())
|
|
{
|
|
|
|
// Get a job off the list. If a userID was
|
|
// specified then print identification information
|
|
// only if the job's user matches the userID. If
|
|
// no userID was specified then print information
|
|
// for every job on the system.
|
|
Job j = (Job) list.nextElement();
|
|
|
|
if (userID != null)
|
|
{
|
|
if (j.getUser().trim().equalsIgnoreCase(userID))
|
|
{
|
|
System.out.println(j.getName().trim() + "." +
|
|
j.getUser().trim() + "." +
|
|
j.getNumber());
|
|
}
|
|
}
|
|
else
|
|
System.out.println(j.getName().trim() + "." +
|
|
j.getUser().trim() + "." +
|
|
j.getNumber());
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
System.out.println("Unexpected error");
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Display help text when parameters are incorrect.
|
|
void showHelp()
|
|
{
|
|
System.out.println("");
|
|
System.out.println("");
|
|
System.out.println("");
|
|
System.out.println("Parameters are not correct. Command syntax is:");
|
|
System.out.println("");
|
|
System.out.println(" listJobs2 System UserID Password");
|
|
System.out.println("");
|
|
System.out.println("Where");
|
|
System.out.println("");
|
|
System.out.println(" System = server to connect to");
|
|
System.out.println(" UserID = valid userID on that system ");
|
|
System.out.println(" Password = password for the UserID (optional)");
|
|
System.out.println("");
|
|
System.out.println("For example:");
|
|
System.out.println("");
|
|
System.out.println(" listJobs2 MYAS400 JavaUser pwd1");
|
|
System.out.println("");
|
|
System.out.println("");
|
|
}
|
|
}</pre>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html> |