Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serializing a script

Status
Not open for further replies.

RPrinceton

Programmer
Jan 8, 2003
86
US
Hi all,
I am relatively new to CGI and PERL, but not to programming so please bear with me. I believe I have a situation where person A executes a script followed closely by person B executing the same script, resulting in person A's variables getting overlayed by person B's variables. Is there any way in CGI/Perl to "serialize" the usage of the script i.e., don't allow person B to execute the script until person B is done? How do I ensure uniqueness of variables when multiple users are using the same script?
Please advise. Thx in advance.
Regards,
Randall Princeton
 
I'm pretty sure that two executions of a script have their own memory space in which to store variables. Can you give a little more detail on what your script does? Does it write anything to disk?

 
Hi Philote,
Thx for your response.
Simply stated the script obtains information from form fields in an HTML page and updates a MySQL database using the data passed from the form. Thru the various scripts I use the same variable names e.g., fld_a on the database is always referenced as fld_a etc.
Regards,
Randall Princeton
 
If the form and the script are on a web server and the form is calling the cgi script, then each time the script is called, a new instance, or thread, of the script is created. If this is the case, the two scripts never "talk" to each other and the variables are never compromised.

However, you may be experiencing a problem of two instances of the script trying to access the same record of the database. With MySql, this is not normally a problem but you may need to invoke some sort of record locking scheme to protect data integrity.

There's always a better way. The fun is trying to find it!
 
Never talk to each other unless you're passing a thread value to overwrite your DB value?

Could this be the issue?

--Paul



It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top