how to make a bash script that can be executed by people simultaneously?

dear friends,

i want to make a bash script that can be executed by many people simultaneously. do you have any idea to make it?
there will be many dependent-variables(which is input from people) in the scripts.
i am thinking about a random temporary file that created by the bash script each time someone executed it(the bash script), so when 8 people executing the bash script there will be 8 different temporary files.
i just don't know where to start... :frowning:

please help me :slight_smile:

thanks alot guys

You don't need to use temporary files - just store the values in variables inside the script and process them accordingly. Each different person running the script will be executing a seperate instance of the script so the variables only have scope within that instance.

If you want to use temporary files and need unique filenames for each script invocation, use $$ when you create the file, e.g.

TMPFILE="tmpfile_`date +%d%m%y`.$$"
echo "some value" >> ${TMPFILE}

$$ is the current processes PID and will be unique for each invocation.

Cheers
ZB

Wouldnt it better off using $USER instead of $$. I have had an instance where $$ was being used. And no matter how rare it could be, $$ did overlap once.

Vino

Even better would be

filename.`date +%d%m%y`.$USER.$$

At least that way if the user spawned two copies of the script (for whatever reason) the files wouldn't interfere with one another.

Cheers
ZB

they work well guys,

thanks alot,

this helps me so much :slight_smile: