Hello, few questions (output to and shell commands)

ddstar

New Member
Hey guys / gals,

Just have a simple question I'm sure is completely easy to most.

We have a procedure that dumps data to a .txt file via comma delimination

Something like this:

Output to file.txt
Export delimiter "," <data here>

The problem is the file does not store a record on a single line, rather it ends the line with a weird block-like character and continues to dump the data. We would like to have it send a new-line break at the end of a row.

We are exporting from Solaris to Windows OS.

Secondly.. if I was to run a progress procedure from the unix command prompt how would I go about doing that (we have a multi-user)

Something like this?

/path/to/mbpro -pf preference.pf -p procedure.p

????

Thanks for all your help!
-ddstar
 
UNIX and Windows use different newline characters. So if you're creating the export on UNIX and then moving it to Windows a Windows tool may not render the newline the way that you expect. Usually you would first use some sort of filter program before transferring the file. Or you would use a tool that knows about both formats to view or manipulate the file on Windows. (These days most tools can deal with both formats -- a notable exception is notepad.exe, if you're using that to view the file try wordpad instead.)

Your mpro command syntax looks fine to me.
 
Hey Tom:

Thanks for the reply, I guess I'll be more specific as to what we are trying to do.

The solaris machine that is running progress is on a network, primarily a windows network. The solaris machine runs a procedure to dump data into a shared network folder.. we are trying to automate this process (cron job, hence the command line question) so one of our employees does not have to do this every day, three times a day.

Supose I had this procedure and I included the command:

OS-COMMAND SILENT unix2dos <filename>

This would solve our line break problem.

The next thing to do is a cron job on this procedure how would I run this procedure in SILENT mode and exit once it is done? Does mpro create an interactive client?

Thanks tom
 
You would want to use mbpro -- the added "b" makes it a batch client. Or add -b to your command line.

You will also need to redirect output:

Code:
mpro dbname -b -pf something.pf -p myprocedure.p > logfile.log
 
Thanks again tom,

We decided to do a command at the end of the procedure:

OS-COMMAND SILENT unix2dos <fileNameHere.txt>

This fixes all the return breaks.

As far as the command you have quoted I think mbpro is what we want right? It just runs in batch mode the mpro doesn't look like it includes a procedure variable in the function.
 
As far as the command you have quoted I think mbpro is what we want right? It just runs in batch mode the mpro doesn't look like it includes a procedure variable in the function.


You can change the startup program with the -p option and pass in a parameter with the -param option that you can check using the session:parameter in your Progress program.


Code:
mpro dbname -b -pf something.pf -p myprocedure.p -param "StartProg=program1.p,OutputFilename=Outfile.txt" > logfile.log


Code:
DEFINE VARIABLE cRunProgram AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFilename   AS CHARACTER NO-UNDO.
  
RUN p_get_parameters.
MESSAGE cRunProgram SKIP cFilename VIEW-AS ALERT-BOX.
PROCEDURE p_get_parameters:
  DEFINE VARIABLE cProgressParam AS CHARACTER NO-UNDO.
  DEFINE VARIABLE iParamLoop     AS INTEGER NO-UNDO.
  DEFINE VARIABLE cEntry         AS CHARACTER NO-UNDO.

  ASSIGN cProgressParam = SESSION:PARAMETER.
  
  DO iParamLoop = 1 TO NUM-ENTRIES (cProgressParam):
    ASSIGN cEntry = ENTRY (iParamLoop,cProgressParam).
    IF NUM-ENTRIES (cEntry,"=") = 2 THEN
        CASE ENTRY (1,cEntry,"="):
            WHEN "StartProg"      THEN ASSIGN cRunProgram = ENTRY (2,cEntry,"=").
            WHEN "OutputFilename" THEN ASSIGN cFilename   = ENTRY (2,cEntry,"=").
        END CASE.
  END.
END PROCEDURE.

So, for example, you could have a generic startup program startup.p that does some processing, creates a session record, sets the propath, connects to databases and runs whichever program is specified in -param.
 
How about just doing this:

[FONT=&quot]# run /path/to/procedure.p

Sounds simple enough..

I'm trying to add this to a cron job.
[/FONT]
 
Good luck with that :lol:

Yeah, thanks. I figured that was a progress command and could not be called externally on the OS side.

Anyway we will just create a shell script and run it on a cron, we've got everything working so far.

Thanks for your help tom.
 
Back
Top