It's John.


This is the CL fragment. Can be CLLE or CLP:

PGM

DCL VAR(&MSGQ) TYPE(*CHAR) LEN(10) VALUE('*SYSOPR')

DCL VAR(&MSGTXT) TYPE(*CHAR) LEN(60)

DCL VAR(&SFTPERR) TYPE(*CHAR) LEN(1) VALUE('N')



SFTP:

CHGVAR VAR(&MSGTXT) VALUE('SPBTLPCL - sFTP to +

starting')

SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSGTXT) +

TOMSGQ(&MSGQ)

ADDENVVAR ENVVAR(USER) VALUE('username') +

REPLACE(*YES)

ADDENVVAR ENVVAR(PASSWORD) VALUE('password') +

REPLACE(*YES)

ADDENVVAR ENVVAR(PUTFILE) VALUE(FILENAME) REPLACE(*YES)



/* Tell QSH to send escape messages instead of */

/* completion messages. Escape message can be */

/* monitored. */

ADDENVVAR ENVVAR(QIBM_QSH_CMD_ESCAPE_MSG) VALUE(Y) +

REPLACE(*YES)



/* Adding this environment variable suppresses output */

/* to the screen or a spool file when in batch. */

ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) VALUE(NONE) +

REPLACE(*YES)

QSH CMD('/usr/local/bin/trl_print.scr')

/* Check for sFTP error */

MONMSG MSGID(QSH0005 QSH0006 QSH0007) EXEC(DO)

CHGVAR VAR(&SFTPERR) VALUE('Y')

ENDDO



/* FTP FAILED */

IF COND(&SFTPERR *EQ 'Y') THEN(DO)

CHGVAR VAR(&MSGTXT) VALUE('SPBTLPCL - sFTP to +

FAILED')

SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +

MSGDTA(&MSGTXT) TOMSGQ(&MSGQ)

ENDDO



/* FTP SUCCESS */

IF COND(&SFTPERR *EQ 'N') THEN(DO)

CHGVAR VAR(&MSGTXT) VALUE('SPBTLPCL - sFTP to +

SUCCEEDED')

SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +

MSGDTA(&MSGTXT) TOMSGQ(&MSGQ)

ENDDO

END:

ENDPGM



And, this is the sFTP script:

#!/bin/sh

build_script() {

cat <<End-of-message
#!/usr/local/bin/expect -f
set timeout 60
spawn /QOpenSys/usr/bin/sftp ${USER}@ftpsite.trilogihealth.com
expect {
default {exit 2}
"Connecting to ftpsite.trilogihealth.com...\r\n"
}
expect {
default {exit 2}
"password"
}
send "${PASSWORD}\n"
expect {
default {exit 4}
"sftp>"
}
send "cd ftp/STFranIBs\n"
expect {
default {exit 5}
"sftp>"
}
send "put ${PUTFILE}\n"
expect {
default {exit 6}
"sftp>"
}
send "quit\n"
exit 0
End-of-message

}

build_script | /usr/local/bin/expect -f -



Note on the last line above: it is a hyphen, followed immediately by
an "f" and then at least one space and another hyphen.

John McKee


On Wed, Jan 18, 2012 at 3:55 PM, Jeff Young <jyoung0950@xxxxxxxxx> wrote:
Jim,
Thanks for the info.
If you have any samples on creating a script that will accept variables and
a CL that shows how to pass those variables, I would greatly appreciate it.

Thanks again,

On Wed, Jan 18, 2012 at 4:52 PM, jmmckee flinthills.com <
jmmckee@xxxxxxxxxxxxxx> wrote:

This not *the* authoritative answer, but here goes:

1 Easiest way is to use PuTTY from a pc to your i.  Log in with your i
credentials.
  then, sftp username@domain to the remote location.  Replace
username and domain.  You will then be asked if you want to import the
public key from the remote system.  Answer yes.

2 Use a script.  Scott has information on building the script.
Typically requires the use of the expect command to look for prompts
from the remote system and send back appropriate values.  I have
several I use.  Can't get to them right now.  I can send one that has
been a bit obfuscated in a few minutes.

3 In the CL, use ADDENVVAR command.  Set value to the path of the
file.  If remote system is not an i, beware sending packed data as it
will be corrupted.


4 Yes, to an extent.  The imported public key is stored in the .ssh
directory in the home directory for the user.  Public key would have
to be imported for each user, or the CL could be submitted to run as a
specific user.

5 Standard restrictions - need *USE.

6 Standard sftp port - I'm not sure what number that is.

Not the full answer, but, I ca send you a script and a snippet of CL
that runs it in a bit.

John McKee



On Wed, Jan 18, 2012 at 3:23 PM, Jeff Young <jyoung0950@xxxxxxxxx> wrote:
All,
I have reviewed Scott Klements' presentation on SFTP, but still have some
questions.
The system will be acting as a Client for this purpose and sending a set
of
files to the server.

I will have a CL program that will drive all processing.
The process will run in the batch.

1. When I get the public key from the server, what do I do to install it?
2. I will be sending multiple files to the server and would like to
automate the process.  What is the best way to do this?
3. The member name of the files being sent will vary with each
transmission.  How can I do this in an automated envrionment?
4. Does it matter what user profile runs the job?
5. What OS Level security restrictions are there on using the required
commands?
6. If the client has a firewall that restricts outbound transmissions to
known ports, what ports need to be opened for SFTP?

Thanks,

Jeff Young
Sr. Programmer Analyst
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.




--
Jeff Young
Sr. Programmer Analyst
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.