1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00
samba-mirror/testprogs/ejs/ejsnet.js
Rafal Szczesniak 262dc06b99 r23178: add simple js code I use for testing and which starts to look like
ejsnet command line utility (perhaps to be moved to utils later...)

rafal
(This used to be commit 43f9d9ba71)
2007-10-10 14:53:00 -05:00

47 lines
812 B
JavaScript
Executable File

#!/usr/bin/env smbscript
libinclude("base.js");
/* note: these require specifying a proper path in "js include" parameter */
libinclude("ejsnet/netusr.js");
libinclude("ejsnet/nethost.js");
function PrintNetHelp()
{
println("Usage: ejsnet.js <cmd> [options]");
}
/* here we start */
var options = GetOptions(ARGV,
"POPT_AUTOHELP",
"POPT_COMMON_SAMBA",
"POPT_COMMON_CREDENTIALS");
if (options == undefined) {
PrintNetHelp();
return -1;
}
if (options.ARGV.length < 1) {
PrintNetHelp();
return -1;
}
/* use command line creds if available */
var creds = options.get_credentials();
var ctx = NetContext(creds);
var cmd = options.ARGV[0];
if (cmd == "user") {
UserManager(ctx, options);
} else if (cmd == "host") {
HostManager(ctx, options);
} else {
PrintNetHelp();
return -1;
}
return 0;