× 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.



This is such any easy thing to do with a little bit of REXX script.
No need to compile a thing.
If you've never used REXX, it comes free with the iSeries.
Just open any source member using SEU and give it a source type of REXX.
Then enter the following REXX script, changing the login and folder
names to your own.

/* Set unique file name */
DATTIM = ' '
"RTVSYSVAL SYSVAL(QDATETIME) RTNVAR(&DATTIM)"
SUFFIX = substr(DATTIM,1,14)
TOFILE = 'MTRINDEX'||SUFFIX||.CSV

/* Populate FTPINFILE with FTP script */
"OVRDBF FILE(STDOUT) TOFILE(FTPINPFILE)"
SAY "MYUSRNAM MYUSRPWD"
SAY "NAMEFMT 1"
SAY "LCD /home/ftp/srcfiles"
SAY "CD /home/ftp/tgtfiles"
SAY "PUT testfile.txt" TOFILE
SAY "QUIT"

/* Run FTP from script */
"OVRDBF FILE(INPUT) TOFILE(FTPINPFILE)"
"OVRDBF FILE(OUTPUT) TOFILE(FTPOUTFILE)"
"FTP RMTSYS(MYREMOTE)"

EXIT

Say you named this source member FTPSCRIPT in source file
MYSRCLIB/MYSRCFILE
To run it just run the following command -
STRREXPRC SRCMBR(FTPSCRIPT) SRCFILE(MYSRCFILE/MYSRCLIB)

An presto /home/ftp/srcfiles/testfile.txt will be FTP'ed to folder
/home/ftp/tgtfiles/MTRINDEX20090106085612.CSV
on system MYREMOTE (the suffix being the current datetime)

If it fails the log will be in FTPOUTFILE in QTEMP

Cheers, Peter




-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of
THarteau@xxxxxxxxxxxxxxxxxx
Sent: Tuesday, 6 January 2009 4:17 a.m.
To: RPG programming on the IBM i / System i
Subject: Embedded SQL to Dynamically Change an FTP Script

Hi,
I need to FTP a file several times a day. This file needs a
unique name. I set up a script and I am trying to change the PUT command
using SQL in an RPG program. If I put it in debug, the statements look
ok, but when I view the script, it has not changed.
This is my code:
D PutWrd C CONST('''PUT''')
D Put1 C CONST('PUT V64BPCSPGM/HTZ
MTRIndex')

D Put3 C CONST('.CSV')
D Udt1 C 'UPDATE V64BPCSUSR/FTPMTRINDX SET
+
D FTPINPUT = '
D Ware C 'WHERE SUBSTR(FTPINPUT,1,3) = '

C EVAL PutCmd = Put1 + DatTmA + Put3
C EVAL SqlSmt =
C Udt1 + PutCmd + Ware + PutWrd
C******************************
C/EXEC SQL
C+ PREPARE STMT FROM :SQLSMT
C/END-EXEC
C******************************
C/EXEC SQL
C+ EXECUTE STMT
C/END-EXEC
C******************************

And this is my script:
CD MTR
PUT V64BPCSPGM/HTZ MTRINDEX.CSV
QUIT

There is a USER line at the beginning. MTRINDEX.CSV should be
MTRINDEX20090105091532

Any ideas what I am doing wrong? Thanks!

<===================================================>

Terri Harteau
Felker Brothers Corporation
****************
"Do not follow where the path may lead. Go instead where there is no
path and leave a trail."
Ralph Waldo Emerson

****************



--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.

#####################################################################################
This correspondence is for the named person's use only. It may contain confidential or legally privileged information, or both. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this correspondence in error, please immediately delete it from your system and notify the sender. You must not disclose, copy or rely on any part of this correspondence if you are not the intended recipient. Any views expressed in this message are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of Veda Advantage. If you need assistance, please contact Veda Advantage on either :- Australia 133124 or New Zealand +64 9 367 6200

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.