Please don't encourage people to put together a kludge like this. You
shouldn't call the programs in the QSHELL library directly. If you want
to run QShell's CHMOD program, please do this:
QSH CMD('chmod 644 /your/file/name')
Do not call the CHMOD program in QShell directly. It may work now, but
break with a PTF or future release. The programs in the QSHELL library
are designed to be used within the QShell environment and pay expect
that environment to be active. Since IBM does not offer them as APIs,
that behavior can change without notice.
If you just want to do a chmod from a CL program, and you don't want to
use CHGAUT, then please use the chmod API.
PGM
DCL VAR(&PATH) TYPE(*CHAR) LEN(255)
DCL VAR(&NULL) TYPE(*CHAR) LEN(1) VALUE(x'00')
DCL VAR(&ZPATH) TYPE(*CHAR) LEN(256)
DCL VAR(&MODE) TYPE(*INT) LEN(4)
DCL VAR(&RC) TYPE(*INT) LEN(4)
CHGVAR VAR(&PATH) VALUE('/your/file/name')
CHGVAR VAR(&MODE) VALUE(420)
CHGVAR VAR(&ZPATH) VALUE(&PATH *TCAT &NULL)
CALLPRC PRC('chmod') PARM((&ZPATH *BYREF) +
(&MODE *BYVAL)) +
RTNVAL(&RC)
IF (&RC *EQ -1) DO
/* chmod failed */
ENDDO
ENDPGM
But I *really* doubt this is helpful, since Frank isn't trying to change
it on *his* system, he's trying to change it on someone else's system.
And I doubt he has the ability to log onto that system and run a CL
program! (If it's even running IBM i!)
Typically, permissions are controlled by the "receiving" system, not by
the sender.
Some FTP software (I've only seen this on Unix servers) has a 'site
chmod' FTP command that can be used to set permissions. It might be
worth looking to see if that's available or not... If not, you're
looking to issue a remote command to change the permissions. (Or telling
the administrator of the system to administer it properly, so it assigns
the permissions the way it's supposed to.)
On 12/17/2010 8:47 AM, Mark S. Waterbury wrote:
Hi, Frank:
You can invoke the "chmod" program directly from an OS/400 command line,
as follows:
CALL PGM(QSHELL/CHMOD) PARM('644' '/your/file/name')
You can call it from within a CL program, as follows:
DCL VAR(&AUTH) TYPE(*CHAR) LEN(4)
DCL VAR(&PATH) TYPE(*CHAR) LEN(255)
DCL VAR(&NULL) TYPE(*CHAR) LEN(1) VALUE(X'00')
...
CHGVAR VAR(&AUTH) VALUE('644' *CAT&NULL)
CHGVAR VAR(&PATH) VALUE(&PATH *TCAT&NULL)
CALL PGM(QSHELL/CHMOD) PARM(&AUTH&PATH)
...
Or, you could use the "native" OS/400 CHGAUT command. Type CHGAUT and
press F4=Prompt.
HTH,
Mark S. Waterbury
As an Amazon Associate we earn from qualifying purchases.