Logging on to a Server
You can use the Logon method (function) from your program or script to log on to a z/OS server. An example of when you would use Logon is when your program or script is accessing a data set on a z/OS server.
The following scripts illustrate how to log on to a z/OS server.
...
VBScript Example
'*********************************************************************
'
' VBScript Example
'
' File Name: Logon.vbs
'
Description: Log on to server. If userid and password not specified,
' user will be prompted.
'
Usage: Logon.vbs <server> [<userid>] [<password>] [<newpassword>]
'*********************************************************************
Dim strServerName
Dim strUserId
Dim strPassword
Dim strNewPassword
Dim objNetwork
Dim objServer
'----------------------------
' Get command line arguments
'----------------------------
If WScript.Arguments.Count < 1 Then
WScript.Echo "Usage: Logon.vbs <server> [<userid>] [<password>] _
[<newpassword>]"
WScript.Quit(1)
End If
strServerName = WScript.Arguments(0)
If WScript.Arguments.Count > 1 Then
strUserId = WScript.Arguments(1)
Else
strUserId = ""
End If
...
If WScript.Arguments.Count > 2 Then
strPassword = WScript.Arguments(2)
Else
strPassword = ""
End If
If WScript.Arguments.Count > 3 Then
strNewPassword = WScript.Arguments(3)
Else
strNewPassword = ""
End If
'------------------
' Log on to server
'------------------
Set objNetwork = CreateObject("ZosCom.ZosNetwork")
Set objServer = objNetwork.Server(strServerName)
objServer.Logon strUserId, strPassword, strNewPassword
WScript.Echo "Logon: Server=" & strServerName, "UserId=" & strUserId
JScript Example
/*********************************************************************
* File Name: Logon.js
*
Description: Log on to server. If userid and password not specified,
* user will be prompted.
*
Usage: Logon.js <server> [<userid>] [<password>] [<newpassword>]
*********************************************************************/
var strServerName;
var strUserId;
var strPassword;
var strNewPassword;
var objNetwork;
var objServer;
...
//////////////////////////////
// Get command line arguments
//////////////////////////////
if (WScript.Arguments.Count() < 1)
{
WScript.Echo("Usage: Logon.js <server> [<userid>] [<password>] _
[<newpassword>]");
WScript.Quit(1);
}
strServerName = WScript.Arguments(0);
if (WScript.Arguments.Count() > 1)
{
strUserId = WScript.Arguments(1);
} else
{
strUserId = "";
}
if (WScript.Arguments.Count() > 2)
{
strPassword = WScript.Arguments(2);
} else
{
strPassword = "";
}
if (WScript.Arguments.Count() > 3)
{
strNewPassword = WScript.Arguments(3);
} else
{
strNewPassword = "";
}
////////////////////
// Log on to server
////////////////////
objNetwork = new ActiveXObject("ZosCom.ZosNetwork");
objServer = objNetwork.Server(strServerName);
objServer.Logon(strUserId, strPassword, strNewPassword);
WScript.Echo("Logon: Server=" + strServerName, "UserId=" + strUserId);