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
------------------------------
The ESC:STX command tells AccuTerm to execute something on your local machine. It's not running the command on the Linux host. I assume that what you're trying to do is make your host machine connect to the ftp server and download the files. Is that correct?
If you're connected to a Linux machine there are a number of methods you can use. If you're using Universe you can use the SH command to execute a Linux command. You can use the pipe function to feed a file into the command or write a bash script on the fly and execute it.
What version of MVDB are you using and what version of Linux are you connecting to?
------------------------------
Joe Goldthwaite
Consultant
Phoenix AZ US
------------------------------
The ESC:STX command tells AccuTerm to execute something on your local machine. It's not running the command on the Linux host. I assume that what you're trying to do is make your host machine connect to the ftp server and download the files. Is that correct?
If you're connected to a Linux machine there are a number of methods you can use. If you're using Universe you can use the SH command to execute a Linux command. You can use the pipe function to feed a file into the command or write a bash script on the fly and execute it.
What version of MVDB are you using and what version of Linux are you connecting to?
------------------------------
Joe Goldthwaite
Consultant
Phoenix AZ US
------------------------------
Yes, I tried putting something in linux and then using accuterm to kick it off but it couldn't get past the login and password - I've not really done any scripts
we're on universe 11 and linux redhat
------------------------------
Kathleen Hambrick
Programmer at Colwell
------------------------------
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
------------------------------
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
------------------------------
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
------------------------------
Joe, thank you so much for your detailed example. I am one of those people that needs to see something to understand. Someone telling me the whats and whys does not help me but given an example I can make almost anything work from it!
I was able to create a single line command with the information parsed with attribute marks work, and also creating the record out in linux with the vi editor. I will use the writeseq to make this work on the fly with different data.
One thing that wasn't working and that I did get to work, in case anyone else wants to try this, is that I needed the '192.168.22.NNN' included in the FTP command (ftp 192.168.22.NNN < KTEST), and the login info in this format: "user ibmftp password"
Thanks again for your help (you too Pete Gonzalez)!
------------------------------
Kathleen Hambrick
Programmer at Colwell
------------------------------
Yes, I tried putting something in linux and then using accuterm to kick it off but it couldn't get past the login and password - I've not really done any scripts
we're on universe 11 and linux redhat
------------------------------
Kathleen Hambrick
Programmer at Colwell
------------------------------
We use scripts all the time. Currently we are on RHEL 7 and UV 11.3.4 but we did the same on earlier versions and on AIX.
I create a type 1 file so I can create the data and write it to the type 1 file.
then I move the data
TEMP = 'SH -c "cp /snap2/driver.handbook.txt /u2/PCDIR/DRIVER.SENT"'
EXECUTE TEMP CAPTURING JUNK
Then I run the script I created
XX = 'SH -c /u2/ftpfiles/ksmidt/ediphput'
EXECUTE XX
Script
cd to location I moved the file
ftp -nv partnertest.xxx.com < /u2/ftpfiles/vitro/test.put
user cmbd abcd (User name and password)
passive
cd /to_tpc
put *
bye
You can do something simular if it is sftp but if they need you to include a password use sshpass to push the password.
Jon Card
Combined Transport Inc
------------------------------
Jon Card
VP
Combined Transport Inc
Central Point OR US
------------------------------
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
------------------------------
Kathleen,
;
While I realise this query is about UNIX, for reference there is a similar Rocket Knowledge article for Windows which rounds out the useful solutions already given and covers another type of failure where 'Passive Mode' mey be required:
Regards,
JJ
------------------------------
John Jenkins
Thame, Oxfordshire
------------------------------
Kathleen,
;
While I realise this query is about UNIX, for reference there is a similar Rocket Knowledge article for Windows which rounds out the useful solutions already given and covers another type of failure where 'Passive Mode' mey be required:
Regards,
JJ
------------------------------
John Jenkins
Thame, Oxfordshire
------------------------------
Hi John - thanks for the info.
I did get this to work without the 'passive' - but that is a good thing to know! I see Jon Card also suggested that above. There were some command lines that worked when typing them in through the shell that did not work the same in a script. I also do capture the error messages in the PICK program so that any errors aren't lost.
Thanks for the help! Greatly appreciated.
------------------------------
Kathleen Hambrick
Programmer at Colwell
------------------------------