LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-03-2005, 09:58 AM   #1
anirudh
Member
 
Registered: Aug 2004
Location: bangalore india
Posts: 50

Rep: Reputation: 15
Unhappy linux scripting help


i have a script whic does a simple copy of a file from one folder to another
but the execution of this script is through oracles scheduler
so i want to find out as what os user is the script been run
also i want to get the procees id of the procees that has run the script
how can i do this
or is there a way to capture the user that is runnig the script in a variable a put it into a file
 
Old 03-03-2005, 10:21 AM   #2
Technoslave
Member
 
Registered: Dec 2003
Location: Northern VA
Posts: 493

Rep: Reputation: 30
The script is probably being run as the user that executes the oracle scheduler ( user oracle maybe? )

In the script you can do things like echo `id` >> /tmp/id_of_user

As well as echo $$ >> /tmp/process_id

Or something like that to get the info you need.
 
Old 03-03-2005, 11:10 AM   #3
anirudh
Member
 
Registered: Aug 2004
Location: bangalore india
Posts: 50

Original Poster
Rep: Reputation: 15
the script is supposed to run as nobody the lowest privileged user
but how can i find out if or not the script was run as nobody
or some other user which depends on the owner of the extjob in oracle bin folder. i just need to find this out which user is running the script at os level
 
Old 03-03-2005, 11:15 AM   #4
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
You can tell the script to run 'whoami':
Code:
itsme@dreams:~/scripts$ cat who.sh
#!/bin/sh

whoami
itsme@dreams:~/scripts$ ./who.sh
itsme
itsme@dreams:~/scripts$
 
Old 03-03-2005, 11:19 AM   #5
Technoslave
Member
 
Registered: Dec 2003
Location: Northern VA
Posts: 493

Rep: Reputation: 30
I've already given you the answer to how to run it, itsme86 is just telling you how to do it in a different way.
 
Old 03-04-2005, 05:19 AM   #6
anirudh
Member
 
Registered: Aug 2004
Location: bangalore india
Posts: 50

Original Poster
Rep: Reputation: 15
thanks guys with the help
i have found the pid for the process that runs the script. one more thing
how can i find the user associated with this pid
Thnx
Anirudh
 
Old 03-04-2005, 10:33 PM   #7
hk_linux
Member
 
Registered: Nov 2004
Location: India
Distribution: RedHat, PCQLinux, Fedora
Posts: 95

Rep: Reputation: 15
hi,
"ps -axl" will give the PID and the UID.

HTH
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux scripting desheikh Linux - General 2 10-05-2005 05:45 AM
Scripting in Linux Rv5 Programming 2 09-05-2004 10:14 PM
Linux Scripting Help droz578 Linux - Software 0 01-26-2004 07:45 AM
Linux Scripting SainT1337 Linux - General 3 11-30-2003 01:12 PM
Linux scripting... WeNdeL Linux - Newbie 7 10-20-2002 12:48 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration