USER command passing parameter

Kenneth Brody kenbrody at spamcop.net
Fri Feb 28 08:50:34 PST 2014


On 2/28/2014 11:25 AM, Chris Rendall wrote:
> I'm trying to get a list of filenames that end in .PDF.
>
> My first attempt was to use opendir() and nextdir(), but that didn't
> include filenames that were longer than 31 characters.
>
> My next attempt was to use the user command.
>
> I've created a script that takes one parameter for the job folder to look
> in.
>
> My script has two lines:
> cd /jobs/$1/r-cmtrs
> /bin/ls *.pdf
>
> When the filePro code gets to the command: user
> getPDF=/usr/local/bin/getfillermtlpdf, I get an error: cd:
> /jobs//r-cmtrs/filler metal: No such file or directory.   On the next
> filePro line I am passing in the parameter: getPDF=jn,

That is not passing a parameter.  That is sending a value to your script's 
standard input.

> where jn contains
> the job number of the folder I'm looking in for the PDF files.  When I
> modify the script and replace the $1 parameter with a valid job number
> that I'm trying to pass into the command, the user command runs and
> returned the list of PDF files.
>
> It looks like the user command is executing the script as soon as it gets
> to user getPDF=/usr/local/bin/getfillermtlpdf,

That is correct.  That is how USER works.

> but I haven't passed in
> the parameter yet.

Again, "getpdf=jn" is not passing a parameter, but rather sending the value 
to your script's stdin.

>  Is it possible to pass in a parameter for a user
> command?

Currently, you can't pass a variable to the command line.  However, you can 
pass fixed parameters, such as:

     user myscript = /usr/local/bin/myscript param1 param2

> I'm running filePro 5.0.14 on Linux.

Add a "read" statement, and use that for the "parameter":

     read jobno
     cd /jobs/$jobno/r-cmtrs
     /bin/ls *.pdf

Of course, the "right" way to do this is to have the whole thing in a loop, 
and include some "end of list" identifier:

     while read jobno
     do
         cd /jobs/$jobno/r-cmtrs
         /bin/ls *.pdf
         echo "**END**"
     end

Then check for "**END**" in your processing to detect the end of the list.

-- 
Kenneth Brody


More information about the Filepro-list mailing list