The way I do it is perhaps a bit tricky, but it works. Suppose you have a
dx script "yourscript.net". Call that script from a shell script. In that
shell script you can define your variables (which can be obtained from
the command line), write these variable to stdout, directly follow by
your dxscript to stdout, and pipe stdout to dx -script

So in the script, basicly you define

var=filename

and call the dx script via a pipe

echo "filename=$var; 'cat yourdxsctip.net'" |dx -script

That's it!

As an alternative, you can put everthing to a tempory tmp.net file first,
like:

echo filename=$var; > tmp.net

then append your dxscript (with >>)
cat yourdxscript.net >> tmp.net

and process the tmp.net file with dx
dx -script tmp.net

I added an example so you can see if it works

Regards

Eelco van Vliet


On Thu, 16 May 2002, Renato Gomes Damas wrote:

> Hi,
>
> Can some one help me ??
>
> How can I pass a parameter to .net file via "dx -script ..." command ?
>
> I want to pass a file name to my .net file via command line !!!
>
> Thanks a lot.
>
#!/bin/bash

# read first argument
if [ $# -lt 1 ]
then
        echo "Usage: yourscript.sh <filename> [number]"
        exit
fi
FILENAME=$1

# read (optional second argument )
if [ $# -gt 1 ]
then
        NUMBER=$2
else
        NUMBER=1
fi

echo $FILENAME, $NUMBER

# write arguments to stdout, directly follow by your script (using 
# the command expanding `` together with cat) and pipe everythin to dx
echo "filename=\"$FILENAME\";number=$NUMBER; `cat yourscript.net`" | \
dx -script 

#done
// call from shell script with
//filename="test.dat";
//number=10;

macro Loop(file,num)
{
        current=ForEachN(1,num,1);
        Echo(current,": filenaeme",file);
}

Echo("start loop with",filename,number);
Loop(filename,number);

Reply via email to