passing variable to script

Brian K. White brian at aljex.com
Thu Oct 7 09:59:06 PDT 2010


On 10/7/2010 11:34 AM, scooter6 at gmail.com wrote:
> I have an export ascii out put processing script that I want to setup to
> email after it finishes.
>
> Currently, in output processing, I use variables to create filename based on
> today's date, etc and that all works fine
>
>
> Then:  export ascii deb=(fd) r=\n f=|
>
> Then: deb(1)=1, etc, etc, etc
>
> Then: write deb; end
>
> Now, after this finishes with all the records selected via set selection, I
> want to email the file, passing the variable filename to the script
>
> I thought easiest way would be to do a system call at the end, but if I
> change
>
> Then: write deb; end
> to
> Then: write deb
>
> Then: system "path_to_my_script"<  fd
>
> obviously this calls the system call after each record is written to the
> file - resulting in numerous emails of course haha
>
> So, my next thought would be from the menu, to script it as:
>
> /u/appl/fp/rreport ............
> cd /appl/fpmerge
> ./script_name_to_send_email  ???????
>
> So how would I get the filename (fd) as defined in processing, passed to the
> email in the Create Script File (F5) in the define menus??
>
> Either that, or how do I do a system call ONLY after all records have been
> written to my output file??
>
> Thanks for any help


My suggestion for the most self-contained and thus portable and 
maintainable way:

Do the post-processing (send the email in this case) in @done.
This means declare fd with ,g so that it is still available in @done.
And since in this case the value in fd doesn't change during the entire 
run and doesn't depend on any record data, and assuming you have fp 4.8 
or newer, the simplest and best place to declare and fill fd is in 
@once. (no need to check "i did/didn't do this already" on every record)

Lastly, to avoid possible permissions problems, You might need to use a 
system command to create the file before allowing fp to create it. 
Again, best in @once.

top of prc
  normal per-record output processing
  [...]
  end

@once:
  fd(32,*,g) = "/tmp/something.txt" ' don't use rand()!
  ' system "umask 0 ; >" < fd  ' may not need, try without first.
  end

@done:
  close deb
  system "..." < fd
  x = remove(fd)
  end



This way requires no special set up before nor after running 
report/clerk. It's all within the processing table.

-- 
bkw


More information about the Filepro-list mailing list