× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



You can use 'expect' as suggested by Jack. What I've done is use the built-in batch script capability of SFTP. Either way, you'll need to understand shell scripting. My SFTP script is quite flexible as I build in in the shell script. I'll include a modified excerpt of the script below:

--------------------------------------------------
eval SFTP_SCRIPT=/work-directory/sftp_script_$$
echo Build the sftp script . . .
. rm $SFTP_SCRIPT
. touch $SFTP_SCRIPT
echo cd ${6} >> $SFTP_SCRIPT
echo put /work-directory/file-name.asc >> $SFTP_SCRIPT
echo quit >> $SFTP_SCRIPT
echo Transmit the file . . .
. sftp -vvv -b $SFTP_SCRIPT -F ${4} ${DEST_ID} if [[ $? -eq 0 ]] ; then
echo file-name.asc sent to ${DEST_ID}:${6}
echo " "
echo File transmission for session ${2} completed normally.
. rm $SFTP_SCRIPT
return
else
echo SFTP error: An error occurred processing
echo - - sftp -vvv -b $SFTP_SCRIPT -F ${4} ${DEST_ID}
exit
fi
--------------------------------------------------

The following variables are key to understanding the script
${6} is the remote directory
${DEST_ID} is the Remote-user-ID and address (In the format UserID@xxxxxxxxxxx)
${4} is an SFTP configuration file (it makes it easier to modify the keys, UserIDs, etc. for testing and changes)
- Many other values are done with variables where I've put literals in above

The first line assigns a unique name to the SFTP script based on the current process ID. Then I try to remove the script file--just in case it already exists. Touch generates the file in a compatible CCSID. ${6} is a variable passed in to the script which contains the remote (destination) directory. I believe the rest should pretty much make sense. I execute the SFTP command with -vvv which gives me a high level of verbosity in the results. That makes it easier to debug what happened after the fact. The leading dot '.' tells BASH to run the SFTP command in the same process (unix/linux by default likes to spawn a new process to do each function).

Michael Quigley
Computer Services
The Way international
www.TheWay.org

-----Original Message-----
message: 3
date: Thu, 22 Jun 2023 14:43:38 -0600
from: Jack Woehr via MIDRANGE-L <midrange-l@xxxxxxxxxxxxxxxxxx>
subject: Re: SFTP on IBMi

Automate SFTP Transfers Using ?expect?
https://www.seidengroup.com/2022/12/27/automate-sftp-transfers-using-expect/

On Thu, Jun 22, 2023 at 1:59?PM Gary Kuznitz <docfxit@xxxxxxxxxxxx> wrote:

Does anyone have a program to run SFTP on the IBMi?


--

*JACK WOEHR, IBM Champion 2021-2023

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.