Find username of user running the script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find username of user running the script
# 1  
Old 06-09-2008
Find username of user running the script

Hello All,

If I have a simple cgi script and want to find the name of the person accessing the page, is it possible? How do I get the name of this user? Please help.


I was trying a vague method but it doesn't seem to work with all browsers and versions ...
Code:
$val=$ENV{'HTTP_COOKIE'};
$name = (split ('=',(split(';',$val))[1]))[1];
print "$name";

Regards,
garric

Last edited by Yogesh Sawant; 06-09-2008 at 08:01 AM.. Reason: added code tags
# 2  
Old 06-10-2008
This information is not transmitted over HTTP/CGI. If you mean the local user executing the CGI script on behalf of the visitor, then that should be whatever user is running the HTTP daemon, and will not change from one invocation to the next.

If you are setting cookies, then whatever is in those cookies is of course accessible to you, but if you don't know a user in the first place, you cannot get their name into a cookie.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running shell script using different user

Hi, I do SSH to host using credential 'user1/password1' and execute 'wrapper.sh'. I want to execute another script 'another_script.sh' from 'wrapper.sh' script using different credentials say 'user2/password2' and want to make sure that the credential 'user2/password2' is always used to run... (7 Replies)
Discussion started by: Mahesh Desai
7 Replies

2. Shell Programming and Scripting

Passing username and password to a script running inside "expect" script

Hi I'm trying to run a script " abc.sh" which triggers "use.sh" . abc.sh is nothing but a "expect" script which provides username and password automatically to the use.sh script. Please find below the scripts: #abc.sh #!/usr/bin/expect -f exec /root/use.sh expect "*name*" send... (1 Reply)
Discussion started by: baddykam
1 Replies

3. UNIX for Dummies Questions & Answers

Easy Script, just to find the given username if is it online or not

hey guys plz help me..with shell script. i must find the given(the user types a username) username if is it login or not.. i know how to do it logically, but i think that i can't in scripting. Thank you all (5 Replies)
Discussion started by: aintour
5 Replies

4. Shell Programming and Scripting

running script as different user

I have script1 and script2 i have to make a third script say script3 where i have to run script1 as user1 and script2 as user2 i tried using su but is not working ...i have to give the password. i have an option of using "expect" but if i use "expect" i have to keep password in plane text inside... (7 Replies)
Discussion started by: pchangba1
7 Replies

5. Shell Programming and Scripting

Running script from other user rather than login user

Hi, My requirement is that i am login from ROOT in a script but when any command is coming which is logging to sqlplus then i have to run it with normal user as only normal user have permission to connect to sqlplus . i tried making a script like this : #! /bin/ksh su -... (3 Replies)
Discussion started by: rawatds
3 Replies

6. Shell Programming and Scripting

As root , running script as different user with su - problem

Dear All I am running into a situation where I am running a script as another user lets say oracle using su command as below, and the script fails because the .profile of oracle is not executed so the environment variables are not set. cat /etc/passwd | grep oracle... (4 Replies)
Discussion started by: dbsupp
4 Replies

7. UNIX for Advanced & Expert Users

How to find one partucular user logs when there are lots of users running on it

On my application there are lots of users are doing there work or tasks? ...In my SSH or in 'Putty' i am observing logs? Hot to observe one particular 'user' logs.. even through there are lots of users working on it? For EX: i am log in with use rid:nikhil@in.com. another one log in with... (4 Replies)
Discussion started by: ksr.test
4 Replies

8. UNIX for Dummies Questions & Answers

check user id before running script

I am looking for the syntax to check which ID is executing script.sh. If the the ID, is not user1 then I want the script to exit and return to command prompt, if it is user1, then I want the script to continue. Any help would be greatly appreciate. Thank you. Chris (3 Replies)
Discussion started by: cpolikowsky
3 Replies

9. Shell Programming and Scripting

running a script under different user

Hello again, I have a script, basically simple scp to copy files to a local machine for processing. The scp and ssh facilities use a specific user account requiring no password entry , simply /usr/bin/su - radacct however, I need to run this script from cron under a different user account. I... (4 Replies)
Discussion started by: Gary Dunn
4 Replies
Login or Register to Ask a Question