1748156 Members
3963 Online
108758 Solutions
New Discussion юеВ

Informix- moving a file

 
SOLVED
Go to solution
Krista A
Occasional Advisor

Informix- moving a file

In informix code, I know how to write output to a file, but how would I append a datestamp to the end of a file, and them move the file to a different folder once the file has been written to by the program?
Thanks!
7 REPLIES 7
Jonathan Fife
Honored Contributor

Re: Informix- moving a file

I would look into the "run" command, which can execute OS commands from within 4GL.
Decay is inherent in all compounded things. Strive on with diligence
Steve Lewis
Honored Contributor

Re: Informix- moving a file

The other method is to wrap your informix programs inside a shell script, which renames the output / report files as necessary and moves them wherever you need to. These could also decide on the report filename in the first place.

The other method is to generate the correct filename within the program using TODAY/CURRENT keywords into a variable and start the report to the variable name.

Be aware of security implications of using start report to pipe.
Peter Godron
Honored Contributor

Re: Informix- moving a file

Krista,
you could use a stored procedure which uses the "SYSTEM" command.
This procedure would then be called via:
EXECUTE PROCEDURE

Further reading (Can not vouch for the source):
http://docs.rinet.ru/InforSmes/index.htm
Krista A
Occasional Advisor

Re: Informix- moving a file

Jonathan_Fife,
So, by using the run command, you mean that I could do something like:

run mv report.out $HOME/report.out.current year to minute

in the 4gl code?

Thanks.
Jonathan Fife
Honored Contributor
Solution

Re: Informix- moving a file

I'd set the command you want to run to a variable, then run that. eg:

DEFINE runcmd char(80),
returncode int

LET runcmd = "mv report.out $HOME/report.out.", current.year to minute
RUN runcmd RETURNING returncode

I don't have an Informix environment to test on at the moment, but that should be the general gist of the syntax.

HTH
Decay is inherent in all compounded things. Strive on with diligence
Peter Godron
Honored Contributor

Re: Informix- moving a file

Krista,
for 4gl example of running commands please see:
http://aubit4gl.sourceforge.net/aubit4gldoc/manual/html/4GLcoding.html#Reading/Writing%20Outside%204GL

Section
"C Function Calls and "RUN" statements"
Krista A
Occasional Advisor

Re: Informix- moving a file

Thanks to all for your help!