## Creating script file to send AS/400 file to unix using SFTP

90 pts.
Tags:
AS/400
AS/400 scripts
SFTP
Unix
Hi,

I'm using a script file in an AS400's IFS to send a file to a Unix server.

lchdir /SFTP/RMDEDTRC                      cd /var/opt/apps/reporting/prod/dat/in/dvcs put RMDDWKP                                rename RMDDWKP RMDDKEP.TXT                     chmod 0766 RMDDKEP.TXT                     quit

RMDDWKP is the AS400 file.  I want to send it, then rename it.  It can't find RMDDWKP.  Why not?  What is the correct code?

Thanks,Robert

Software/Hardware used:
AS400,Unix

Thanks. We'll let you know when a new response is added.

Here’s the srcipt again:

lchdir /SFTP/RMDEDTRC
cd /var/opt/apps/reporting/prod/dat/in/dvcs
put QGPL/RMDDWKP
rename RMDDWKP RMDDKEP.TXT
chmod 0766 RMDDKEP.TXT
quit

RMDDWKP is the AS400 file. I want to send it, then rename it. It can’t find RMDDWKP. Why not? What is the correct code?

## Discuss This Question: 10 Replies

Thanks. We'll let you know when a new response is added.
• It can't find RMDDWKP. Why not? What is the correct code? It's probably because of this line:
put QGPL/RMDDWKP
I'd guess that there is no subdirectory in your current directory path named QGPL. You probably want something more like this:
put /QSYS.LIB/QGPL.LIB/RMDDWKP.FILE/RMDDWKP.MBR
It's hard to be certain, though, since you didn't tell us where RMDDWKP really is. We don't know what kind of file it is (database or streamfile), so we can't be sure what the correct path should be. If it is a database file, we also should know something about its structure in order to suggest whether or not the transfer makes good sense. If it is a physical file with a single text field, it should be okay. Otherwise, there are probably some missing steps. Tom
report
• Hi Tom, Thanks for helping me. Your 'put' works! However, that didn't fix my problem. In RMDDWKP, an AS400 data base file with multiple fields, the data looks like this: 20101111617420765954403724313246SSR 0220103-DCL 3DCL 201011112010111403034200 When I copy it into the IFS, it changes the format to this: 20101111 617420765954 403724313246 SSR 2 2010 3-DCL 3DCL 20101111 201011 Notice the spaces. That's the real problem. I think that the copy into the IFS is changing the format so I want to get the file directly from the library. Maybe that's not the problem? Thanks, Robert
report
• This is the copy cmd that I'm using: CPYTOIMPF FROMFILE(&AS400LIB/&AS400FILE) + TOSTMF(&FTPDF) MBROPT(*REPLACE) + STMFCODPAG(*PCASCII) RCDDLM(*LF) + DTAFMT(*FIXED)
report
• ...the data looks like this: Is that copy/pasted directly off of a line from the display created by the DSPPFM command? Can you provide the output from DSPFFD for the file? If possible, run DSPFFD OUITPUT(*PRINT). Use iNav to drag the spooled file into a .TXT file on your PC. Copy/paste the field information into a discussion box here. After the paste, select the pasted text, then click the {code} button. That will preserve newline characters for each line and also preserve spacing within each line. Tom
report
• Hi Tom, Yes, I copy/pasted from DSPPFM. Is this ok?
Display Spooled File
File  . . . . . :   QPDSPFFD                         Page/Line   1/1
Control . . . . .                                    Columns     1 - 78
Find  . . . . . .
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+...
5722SS1 V5R4M0  060210      Display File Field Description
Input parameters
File  . . . . . . . . . . . . . . . . . . . :  RMDDWKP
Library . . . . . . . . . . . . . . . . . :  *LIBL
File Information
File  . . . . . . . . . . . . . . . . . . . :  RMDDWKP
Library . . . . . . . . . . . . . . . . . :  DVDCFIL
File location . . . . . . . . . . . . . . . :  *LCL
Externally described  . . . . . . . . . . . :  Yes
Number of record formats  . . . . . . . . . :      1
Type of file  . . . . . . . . . . . . . . . :  Physical
File creation date  . . . . . . . . . . . . :  09/11/00
Text 'description'. . . . . . . . . . . . . :  Rev. Mgmt. DE Detail Trans W
Record Format Information
Record format . . . . . . . . . . . . . . . :  RMDDWK
Format level identifier . . . . . . . . . . :  4D3121D8651C4
Number of fields  . . . . . . . . . . . . . :     14
Record length . . . . . . . . . . . . . . . :     94
Field Level Information
Data        Field  Buffer    Buffer        Field    Column
Field      Type       Length  Length  Position        Usage    Heading
DDPOST     ZONED        8  0       8         1        Both     DDPOST
Field text  . . . . . . . . . . . . . . . :  Snap Shot Date
DDMBR#     ZONED       12  0      12         9        Both     DDMBR#
Field text  . . . . . . . . . . . . . . . :  Member Number
DDRES#     ZONED       12  0      12        21        Both     DDRES#
Field text  . . . . . . . . . . . . . . . :  Res Number
DDREST     CHAR            5       5        33        Both     DDREST
Field text  . . . . . . . . . . . . . . . :  Contract Resort
Coded Character Set Identifier  . . . . . :     37
DDUMTH     ZONED        2  0       2        38        Both     DDUMTH
Field text  . . . . . . . . . . . . . . . :  Use-Month
DDUSYR     ZONED        4  0       4        40        Both     DDUSYR
Field text  . . . . . . . . . . . . . . . :  Use-Year
DDTRIP     CHAR            6       6        44        Both     DDTRIP
Field text  . . . . . . . . . . . . . . . :  DE Trip Code
Coded Character Set Identifier  . . . . . :     37
DDTCAT     CHAR            5       5        50        Both     DDTCAT
Field text  . . . . . . . . . . . . . . . :  DE Trip Category
Coded Character Set Identifier  . . . . . :     37
DDARRD     ZONED        8  0       8        55        Both     DDARRD
Field text  . . . . . . . . . . . . . . . :  Arrival Date
DDDPTD     ZONED        8  0       8        63        Both     DDDPTD
Field text  . . . . . . . . . . . . . . . :  Departure Date
5722SS1 V5R4M0  060210      Display File Field Description
Record format . . . . :  RMDDWK        File . . . :  RMDDWKP      Library . .
Data        Field  Buffer    Buffer        Field    Column
Field      Type       Length  Length  Position        Usage    Heading
DDNGTS     ZONED        2  0       2        71        Both     DDNGTS
Field text  . . . . . . . . . . . . . . . :  Number of Nights
DDPTST     ZONED        4  0       4        73        Both     DDPTST
Field text  . . . . . . . . . . . . . . . :  Points Total
DDCOST     ZONED        9  2       9        77        Both     DDCOST
Field text  . . . . . . . . . . . . . . . :  DVC Cost for Trip
DDDOLR     ZONED        9  2       9        86        Both     DDDOLR
Field text  . . . . . . . . . . . . . . . :  Member Paid in \$\$
report
• Here's RMDDWKP on the AS400:
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....
20011019271500130244366710024520CLUB 122000DCL7  CRUIS2001042120010428070406000324750000000000
20011019262040400066367090026448BWALK022001DCL7  CRUIS2001042120010428070484000385125000000000
20011019260860123936366840025147CLUB 122000DCL7  CRUIS2001042120010428070406000333750000009000
report
• I hope this format is ok. This is RMDDWKP in the IFS:
....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....0....+....1....+....2....+....3....+....4....+....5....+...
************Beginning of data**************
20101111  617420765954  403724313246  SSR  2   2010  3-DCL 3DCL 20101111  20101114  3   342   2393.68    .00
20101111  606931009568  403984316437  BLT  2   2010  RCINTHRCI  20101111  20101114  3   142   .00        .00
20101111  646750726901  403304308639  SSR  3   2010  3-DCL 3DCL 20101111  20101114  3   234   1631.84    .00
Notice the decimal point in the numbers. Thanks for your help, Tom.
report
• However, that didn’t fix my problem. The pasted items came across great. The situation is clear. Now on to "the problem". Are you simply wanting to send an image of the record itself? If so, you might want to create a non-database file container for it:
CRTPF FILE( QGPL/RMDDWKPNDB )  RCDLEN(94)
CPYF FROMFILE( QGPL/RMDDWKP )  TOFILE( QGPL/RMDDWKPNDB )  MBROPT( *REPLACE )  FMTOPT( *NOCHK )
Then you might be able to put /QSYS.LIB/QGPL.LIB/RMDDWKPNDB.FILE/RMDDWKPNDB.MBR. And if that doesn't work directly, you can use CPYTOSTMF to copy RMDDWKPNDB to an IFS streamfile without modification. CPYTOIMPF isn't exactly a "copy" command as much as it is an "export" command. CPYFRMIMPF and CPYTOIMPF provide basic forms of DB2 IMPORT and EXPORT functions. Tom