Hi Greg,
Here is a very quick and simple example of using those API's
PGM
DCL VAR(&ORIGUSER) TYPE(*CHAR) LEN(12)
DCL VAR(&SFTPUSER) TYPE(*CHAR) LEN(12)
MONMSG (CPF0000 MCH0000) EXEC(GOTO DONE)
// Get the profiles handles for *Current and SFTPUSER
CALL PGM(QSYGETPH) PARM(*CURRENT *NOPWD &ORIGUSER)
CALL PGM(QSYGETPH) PARM(SFTPUSER *NOPWD &SFTPUSER)
// Change to SFTPUSER
CALL PGM(QWTSETP) PARM(&SFTPUSER)
// Check what the profile is for the job
wrkjob
// Switch back to the original user
DONE: CALL PGM(QWTSETP) PARM(&ORIGUSER)
// Release the profile handles
CALL PGM(QSYRLSPH) PARM(&ORIGUSER)
CALL PGM(QSYRLSPH) PARM(&SFTPUSER)
endpgm
Â
Don Brown
Senior Consultant
Â
[1]OneTeam IT Pty Ltd
P: 1300 088 400
-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Greg
Wilburn
Sent: Tuesday, 6 May 2025 11:53 PM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: sFTP User Name - does it need to match user name on the
server
Don - that was considered. I had some help offline to possibly do that.
But I've never done that before and I had to get this running quickly.
Maybe give this a shot when I have more time.
-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Don
Brown via MIDRANGE-L
Sent: Thursday, May 1, 2025 5:20 PM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Cc: Don Brown <dbrown@xxxxxxxxxxxxxxxx>
Subject: RE: sFTP User Name - does it need to match user name on the
server
I have not been following this thread closely but is there a reason you
don't just call a CL, do a profile swap, run the copy and switch back ?
With the Get Profile Handle (QSYGETPH) and Set Profile Handle (QWTSETP)
APIs,
Cheers
Don
??
Don Brown
Senior Consultant
??
[1]OneTeam IT Pty Ltd
P: 1300 088 400
-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Greg
Wilburn
Sent: Friday, 2 May 2025 4:02 AM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: sFTP User Name - does it need to match user name on the
server
Patrik,
I don't remove the files completely... I move them to a "processed"
subdirectory after successful upload (I haven't tackled the "successful"
part yet)
So I'm resigned to the fact of submitting the job. I put 30 second delay
in my RPG program after submitting. Hopefully that's enough.
However, if the user calling the program has sufficient authority, the
SFTP as the other user works flawlessly.
Why have the -i and -oUserKnownHostsFile options if this is a security
issue?
Thanks again!
Greg
Greg Wilburn
Director of IT
301.895.3792 ext. 1231
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: [2][2]
https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
[3][3]
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
--
Message protected by MailGuard: e-mail anti-virus, anti-spam and content
filtering.
[4][4]
https://www.mailguard.com.au
References
Visible links
1. [5]
https://www.oneteamit.com.au/
2. [6]
https://lists.midrange.com/mailman/listinfo/midrange-l
3. [7]
https://archive.midrange.com/midrange-l.
4. [8]
https://www.mailguard.com.au/
Greg Wilburn
Director of IT
301.895.3792 ext. 1231
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: [9]
https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
[10]
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
--
Message protected by MailGuard: e-mail anti-virus, anti-spam and content
filtering.
[11]
https://www.mailguard.com.au
References
Visible links
1.
https://www.oneteamit.com.au/
2.
https://lists.midrange.com/mailman/listinfo/midrange-l
3.
https://archive.midrange.com/midrange-l.
4.
https://www.mailguard.com.au/
5.
https://www.oneteamit.com.au/
6.
https://lists.midrange.com/mailman/listinfo/midrange-l
7.
https://archive.midrange.com/midrange-l.
8.
https://www.mailguard.com.au/
9.
https://lists.midrange.com/mailman/listinfo/midrange-l
10.
https://archive.midrange.com/midrange-l.
11.
https://www.mailguard.com.au/
As an Amazon Associate we earn from qualifying purchases.