The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
send a message through email to 5 people using unix script. MARY76 UNIX for Advanced & Expert Users 3 02-05-2007 03:42 PM
send a message through email to 5 people using unix script? MARY76 Shell Programming and Scripting 2 02-05-2007 03:29 PM
Help - Need simple example of VI executed in shell script corsart AIX 2 06-03-2006 06:25 PM
How to make bash script abort? siegfried Shell Programming and Scripting 1 11-23-2005 12:15 PM
bash scripting cannot executed in crontab jimmbp Shell Programming and Scripting 6 11-11-2005 11:23 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-14-2006
jimmbp jimmbp is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 6
Question 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...

please help me

thanks alot guys
  #2 (permalink)  
Old 01-14-2006
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
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
  #3 (permalink)  
Old 01-16-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Quote:
Originally Posted by zazzybob
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.
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
  #4 (permalink)  
Old 01-16-2006
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
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
  #5 (permalink)  
Old 01-31-2006
jimmbp jimmbp is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 6
thanks

they work well guys,

thanks alot,

this helps me so much
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0