This is probably how I would do it. You want to have a file you can pipe into the ftp command to feed it all the parameters. That file would basically be the commands from your example. Lets call it "MY_FTP_PARAMETERS". The contents would be the lines from your example;
ibmftp
**passwd**
cd /BizApp/Parts/Test
binary
put "KAlside.pdf"
bye *
Once you have that file you can execute the following Linux command:
ftp < MY_FTP_PARAMETERS
You can test this from the Linux shell. All you have to do is create the text file with your parameters. I use nano which is a very simple Linux text editor.
Once you have the parameter file working you can use the Universe SH command to execute it. From the Universe TCL prompt:
SH -c "ftp < MY_FTP_PARAMETERS"
Once you've got it working there are a number of ways you can create the parameter file from Universe using Basic. Here are some examples;
* Example 1 of using OPENSEQ to create a linux file.
OPENSEQ "/home/jgold/MY_FTP_PARAMETERS" to PARAMETERS.FILE ELSE
* If the file doesn't exist, this will create it using the PARAMETERS.FILE variable
CREATE PARAMETERS.FILE ELSE
PRINT 'CANNOT CREATE THE PARAMETERS FILE'
STOP
END
END
* write your parameters
WRITESEQ "ibmftp" ON PARAMETERS.FILE ELSE NULL
WRITESEQ '**passwd**' ON PARAMETERS.FILE ELSE NULL
WRITESEQ 'cd /BizApp/Parts/Test' ON PARAMETERS.FILE ELSE NULL
WRITESEQ 'binary' ON PARAMETERS.FILE ELSE NULL
WRITESEQ 'put "KAlside.pdf"' ON PARAMETERS.FILE ELSE NULL
WRITESEQ '' ON PARAMETERS.FILE ELSE NULL
WRITESEQ 'bye' ON PARAMETERS.FILE ELSE NULL
* close the file
CLOSESEQ PARAMETERS.FILE
* execute ftp feeding it the above parameters
CMD = 'SH -c "ftp < /home/jgold/MY_FTP_PARAMETERS"'
EXECUTE CMD
* Example 2. Instead of doing multiple WRITESEQ we'll build the entire file using
* line feeds to separate the parameters and write it all out at once.
OPENSEQ "/home/jgold/MY_FTP_PARAMETERS" to PARAMETERS.FILE ELSE
CREATE PARAMETERS.FILE ELSE
PRINT 'CANNOT CREATE THE PARAMETERS FILE'
STOP
END
END
LF = CHAR(10)
PARAMS = 'ibmftp':LF:'**passwd**':LF:'cd /BizApp/Parts/Test':LF:'binary':LF:'put "KAlside.pdf"':LF:'':LF:'bye'
WRITESEQ PARAMS ON PARAMETERS.FILE ELSE
PRINT 'COULD NOT WRITE PARAMETERS'
STOP
END
CMD = 'SH -c "ftp < /home/jgold/MY_FTP_PARAMETERS"'
EXECUTE CMD
* Example 3 - Use a BP file to write the parameters.
* ON my system I have Universe file named "BP.JG". It's an F pointer to "/home/jgold/BP.JG". When
* I'm logged onto Universe I can access it like any Universe file. Since it's a Universe type 19 files, items
* in the file become normal Linux files.
OPEN 'BP.JG' TO BP.FILE ELSE STOP 201,'BP.JG'
* Lets build a normal attribute delimited dynamic array with our parameters.
PARAMS = 'ibmftp':@AM:'**passwd**':@AM:'cd /BizApp/Parts/Test':@AM:'binary':@AM:'put "KAlside.pdf"':@AM:'':@AM:'bye'
* and just write it to the BP.JG file
WRITE PARAMS ON BP.FILE, 'MY_FTP_PARAMETERS'
* Since the MY_FTP_PARAMETERS item is in the BP.JG file the full path to the item becomes
* /home/jgold/BP.JG/MY_FTP_PARAMETERS. Universe translates the attribute marks to line feeds automatically so
* all you have to do is write the array out. Attributes are converted into lines in the file. You can now
* do the same command passing it the full path.
CMD = 'SH -c "ftp < /home/jgold/BP.JG/MY_FTP_PARAMETERS"'
EXECUTE CMD
STOP
------------------------------
Joe Goldthwaite
Consultant
Phoenix AZ US
------------------------------
Original Message:
Sent: 03-02-2023 15:01
From: Kathleen Hambrick
Subject: FILE IN LINUX TO RUN FTP
I'm trying to create something in linux that I can run from the accuterm esc:stx command. I wanted to connect to FTP, login, and send a get and/or push command but it doesn't seem to be executing the statements:
ftp nnn.nnn.nn.nnn
ibmftp
**passwd**
cd /BizApp/Parts/Test
binary
put "KAlside.pdf"
bye
I've tried 'echo' and using the < to pass in the data... not working. Anyone have something like this?
Thanks
------------------------------
Kathleen Hambrick
Programmer at Colwell
------------------------------