FTP from AIX to Mainframe


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP from AIX to Mainframe
# 15  
Old 12-22-2017
Code:
f_FTP_MVS()
{
	
	echo 'user $REMOTE_USER $REMOTE_USER_PASS' > $TMP_BATCH_FTP
	echo 'type binary' >> $TMP_BATCH_FTP
	echo 'passive' >> $TMP_BATCH_FTP
	cat $TMP_BATCH_FILE >> $TMP_BATCH_FTP
	echo 'bye' >> $TMP_BATCH_FTP
	ftp -sinv $REMOTE_SERVER $REMOTE_PORT << `cat $TMP_BATCH_FTP`
}

In the above code, I am creating a batch file on the fly and using it in FTP command.

Is the usage correct? I don't see it working.
# 16  
Old 12-27-2017
Lightbulb

Quote:
Originally Posted by TechGyaann
Code:
f_FTP_MVS()
{
	
	echo 'user $REMOTE_USER $REMOTE_USER_PASS' > $TMP_BATCH_FTP
	echo 'type binary' >> $TMP_BATCH_FTP
	echo 'passive' >> $TMP_BATCH_FTP
	cat $TMP_BATCH_FILE >> $TMP_BATCH_FTP
	echo 'bye' >> $TMP_BATCH_FTP
	ftp -sinv $REMOTE_SERVER $REMOTE_PORT << `cat $TMP_BATCH_FTP`
}

In the above code, I am creating a batch file on the fly and using it in FTP command.

Is the usage correct? I don't see it working.

Hi All,

I'm stuck on this., your help is much appreciated.

using below command:
Code:
ftp -siv $REMOTE_SERVER $REMOTE_PORT << `cat $TMP_BATCH_FTP`

still im not able to get what I want.

Thanks.
# 17  
Old 12-27-2017
Please do not bump posts, it's not allowed.

As I said in my post#2, use of a .netrc file should avoid the need to supply a userid/passwd for the ftp server.

Yes, many times I have built a command file to input to ftp:

Code:
$ ftp 'ftpserver' < 'command file' 1> /dev/null

and it works fine. You have to be careful of how to trap errors though. You also need to ensure that the last line of your command file is 'quit' to ensure control is passed to the next line of your script when ftp operation is done.

When you say that it doesn't work; in what way????? Error message or what? Give us all a clue.

Do you need to use a non-standard ftp port? If not, why try and specify it?
This User Gave Thanks to hicksd8 For This Post:
# 18  
Old 12-27-2017
Quote:
Originally Posted by TechGyaann
Code:
f_FTP_MVS()
{
	echo 'user $REMOTE_USER $REMOTE_USER_PASS' > $TMP_BATCH_FTP
	echo 'type binary' >> $TMP_BATCH_FTP
	echo 'passive' >> $TMP_BATCH_FTP
	cat $TMP_BATCH_FILE >> $TMP_BATCH_FTP
	echo 'bye' >> $TMP_BATCH_FTP
	ftp -sinv $REMOTE_SERVER $REMOTE_PORT << `cat $TMP_BATCH_FTP`
}

In the above code, I am creating a batch file on the fly and using it in FTP command.

Is the usage correct? I don't see it working.
The correct format for using a here document would be something more like:
Code:
f_FTP_MVS()
{
	ftp -sinv $REMOTE_SERVER $REMOTE_PORT <<EOF
user $REMOTE_USER $REMOTE_USER_PASS
type binary
passive
$(cat $TMP_BATCH_FILE)
bye
EOF
}

But, the AIX ftp man page that I have access to doesn't include a -s option. And, if you're trying to use ftp to copy the content of the file named by the expansion of $TMP_BATCH_FILE from AIX to MVS, the correct way to do that would be something like:
put $TMP_BATCH_FILE
not catting a binary file into a here document.

Alternatively, you could use simple redirection instead of a here-document:
Code:
f_FTP_MVS()
{
	echo "user $REMOTE_USER $REMOTE_USER_PASS" > "$TMP_BATCH_FTP"
	echo 'type binary' >> "$TMP_BATCH_FTP"
	echo 'passive' >> "$TMP_BATCH_FTP"
	echo "put '$TMP_BATCH_FILE'" >> "$TMP_BATCH_FTP"
	echo 'bye' >> "$TMP_BATCH_FTP"
	ftp -sinv "$REMOTE_SERVER" "$REMOTE_PORT" < "$TMP_BATCH_FTP"
}

And, of course, unless the FTP protocol includes character set translations when moving from AIX to MVS... since AIX works in ASCII/ISO 8859-1/UTF-8 and MVS works in EBCDIC, you may also need a step somewhere to convert your ASCII requests and file contents into EBCDIC. One possible way to do that if you need to is with dd conv=EBCDIC or dd conv=IBM depending on which variant of EBCDIC is used on your target MVS system.
This User Gave Thanks to Don Cragun For This Post:
# 19  
Old 12-27-2017
Lightbulb

Quote:
Originally Posted by hicksd8
Please do not bump posts, it's not allowed.

As I said in my post#2, use of a .netrc file should avoid the need to supply a userid/passwd for the ftp server.

Yes, many times I have built a command file to input to ftp:

Code:
$ ftp 'ftpserver' < 'command file' 1> /dev/null

and it works fine. You have to be careful of how to trap errors though. You also need to ensure that the last line of your command file is 'quit' to ensure control is passed to the next line of your script when ftp operation is done.

When you say that it doesn't work; in what way????? Error message or what? Give us all a clue.

Do you need to use a non-standard ftp port? If not, why try and specify it?
Hi hicksd8,

Thanks much for your response.
The intention was not to bump posts.

I was able to connect to the MVS password less using .netrc and give the command to put files into mvs.

Whereas when i create a file dynamically(because i dont know the number of files I will have at any point which is to be ftp'ed) and use it in Ftp command its not working properly.

Output:
Code:
USER@SERVER:MY_PWD>ftp -siv remote_server.abcd.com 12342 << cat /user_home/ftp.batch.file
>

---------- Post updated at 03:18 AM ---------- Previous update was at 03:14 AM ----------

Quote:
Originally Posted by Don Cragun
The correct format for using a here document would be something more like:
Code:
f_FTP_MVS()
{
	ftp -sinv $REMOTE_SERVER $REMOTE_PORT <<EOF
user $REMOTE_USER $REMOTE_USER_PASS
type binary
passive
$(cat $TMP_BATCH_FILE)
bye
EOF
}

But, the AIX ftp man page that I have access to doesn't include a -s option. And, if you're trying to use ftp to copy the content of the file named by the expansion of $TMP_BATCH_FILE from AIX to MVS, the correct way to do that would be something like:
put $TMP_BATCH_FILE
not catting a binary file into a here document.

Alternatively, you could use simple redirection instead of a here-document:
Code:
f_FTP_MVS()
{
	echo "user $REMOTE_USER $REMOTE_USER_PASS" > "$TMP_BATCH_FTP"
	echo 'type binary' >> "$TMP_BATCH_FTP"
	echo 'passive' >> "$TMP_BATCH_FTP"
	echo "put '$TMP_BATCH_FILE'" >> "$TMP_BATCH_FTP"
	echo 'bye' >> "$TMP_BATCH_FTP"
	ftp -sinv "$REMOTE_SERVER" "$REMOTE_PORT" < "$TMP_BATCH_FTP"
}

And, of course, unless the FTP protocol includes character set translations when moving from AIX to MVS... since AIX works in ASCII/ISO 8859-1/UTF-8 and MVS works in EBCDIC, you may also need a step somewhere to convert your ASCII requests and file contents into EBCDIC. One possible way to do that if you need to is with dd conv=EBCDIC or dd conv=IBM depending on which variant of EBCDIC is used on your target MVS system.
Thanks Don.

Since I am polling a directory and don't have any idea of how may files will be there at any given moment, I will have to go by the approach of creating a dynamic file list and give it as input to the ftp command.


I try with your approach and get back here.

To answer your question., the file is already in EBCDIC format and just needs to be transferred in binary mode.


Thanks a lot for your guidance.
# 20  
Old 12-27-2017
Have you considered using:
Code:
lcd <AIX_source_directory>
mput  *

(you may need to play with quoting or escaping the asterisk depending on how you give your ftp commands to ftp).
This User Gave Thanks to Don Cragun For This Post:
# 21  
Old 01-04-2018
I have implemented this., now I want to verify the file

1. To check if file is transferred
2. The file is not corrupt

I have achieved (1) using nlist over FTP., later after closing FTP connection I would grep the nlist target file and get to know if the file is transferred to mainframe.

I am having challenge to ensure we have same bytes transferred to MVS.
I can generate cksum in AIX Unix before/after transferring the file to get checksum and byte size of the file.

may I know how do i get that over FTP for the file transferred to mainframe.
so I can verify both the checksum and bytes.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

AIX Forum: FTP from AIX to Mainframe

This discussion thread is an extension to what was discussed in Shell scripting section. Please refer the post for the requirement: Requirement Post - Click Here The whole thread - Click Here I would like to know how I can use NDM to transfer file from AIX to Mainframe and to verify the... (3 Replies)
Discussion started by: TechGyaann
3 Replies

2. AIX

ODBC Connectivity between Oracle10g on AIX and Mainframe

Hi, I have a task of setting up connectivity between Oracle 10g (AIX) and Mainframe (1 library). Went through couple of documents, forums, blogs etc. MY understanding is ODBC Generic Connectivity is free from Oracle side. Question: (may be dumb to you) 1. Has anybody done this and would... (3 Replies)
Discussion started by: jvmani_1
3 Replies

3. UNIX for Advanced & Expert Users

FTP issues between mainframe and UNIX

Hi All, The issue is that, we have a dataset in mianframe whose record length is 153 characters. And a batch job ftpies it to the unix server(SunOS) as a test file. But the ftpied file in unix does not have a record length of 153 chars. Each record of 153 chars gets splited into two line of... (8 Replies)
Discussion started by: hareeshkumaru
8 Replies

4. AIX

Problems with SSH/SFTP between AIX and Mainframe

Hi, I'm not sure if this has been solved in this forum already but please do help me out if possible. Basically, I've already setup a passwordless SSH connection between 2 AIX IDs (say ID-1 and ID-2) with a Mainframe server ID (say MVSID). I'm able to successfully do an SSH from the AIX server to... (1 Reply)
Discussion started by: sambeet
1 Replies

5. Shell Programming and Scripting

FTP files to target Mainframe system

Hi Experts... Greetings for the day..! I just want to FTP the files to mainframe system.. my code is not working..and also i need to put the files in a particular directory in a specific naming format... ftp -i -n ${HOST_NAME} << END_FTP user ${USER_NAME} ${PASSWORD} put ${FILE_NAME}... (3 Replies)
Discussion started by: spkandy
3 Replies

6. UNIX for Dummies Questions & Answers

FTP'ing EBCDIC Characters from Mainframe

Hi All, I am new to this site, I have a requirement where in i have to FTP a file from mainframe to Unix box. The catch here is there are few Spanish characters like N with tilde(~) and a with ` etc., all other characters are coming fine but those mentioned above are not coming in a proper... (1 Reply)
Discussion started by: harikiranr
1 Replies

7. UNIX for Advanced & Expert Users

ftp file from unix to mainframe

thanks (2 Replies)
Discussion started by: ashishabhishek
2 Replies

8. UNIX and Linux Applications

ftp from unix to Mainframe

suppose i have a file named xyz(-1) and i have to transfer(ftp) it on a Mainframe from unix,how should i do it as whenever i try to do so it says use MVS naming conventions (1 Reply)
Discussion started by: ashishabhishek
1 Replies

9. HP-UX

ftp from unix to mainframe

hi suppose i have a file named xyz(-1) and i have to transfer(ftp) it on a Mainframe from unix,how should i do it as whenever i try to do so it says use MVS naming conventions (1 Reply)
Discussion started by: ashishabhishek
1 Replies

10. Shell Programming and Scripting

mainframe FTP error

Hi when i am trying to ftp to a newly cretaed mainframe GDG for the first time,i am getting the following error... Verbose mode on. 200 Representation type is Ebcdic NonPrint 200 Port request OK. 550-SVC99 Return code=4 S99INFO=0 S99ERROR=38668 HEX=970C S99ERSN code X'00004379'). 550... (1 Reply)
Discussion started by: sam99
1 Replies
Login or Register to Ask a Question