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!

Calling Sub Scripts To Do Stuff.

Status
Not open for further replies.

madaxe2

Technical User
Jan 23, 2005
43
US
I want to write cgi scripts that do stuff then call them from main scripts with input then feed the output back to the main script.

Does anybody have any examples that i can see

also can you run a script constainly in the background to check stuff like whos logged on and outputting the info to a page.

MadAxe
 
Calling a sub routine and returning to the original location with the results:

Code:
$returned = &dosomething;

if($returned =~ /^yes/i)
 {
 #do something
 }
else
 {
 #do something else
 }




sub dosomething
 {
 #do something
 if($condition_met)
  {
   return qq~yes;
  }
 else
  {
  return qq~no;
  }
 }

As far as running a constant CGI script, I am going to say no. Even if you find a way it makes no sence...Why make a page if nobody is looking at it?

CGI is server side, so it is called, runs, and returns an aswer. If you want to keep stats like that just insert them into a database or other file as the event occurs, then create a script to read your current stats.
 
You could capture that information if you stored all user experience in session cookies, but it may not tell you everything you want to know. Say your session is set to stay active for 15 minutes. You'll be told that user A is online for those 15 minutes after they last hit a page, unless they log out of the system (and let's face it, users never log out).

I'd say your best bet though is to log all activity to a database as Rob suggests. This way, you know who did what and when and you have the flexibility of the database to get your information out for administrative use.

- Rieekan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top