LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-30-2008, 10:12 AM   #1
jonhanna
Member
 
Registered: Dec 2008
Posts: 31

Rep: Reputation: 15
question on PID's and Executing a shell script


HI guys I have a couple of questions I need help with or it would be great to be pointed in the right direction.
1. What are a couple ways that i can identify the PID number of my login shell?
2. what are some ways that I can execute a shell script when I do not have execute permissions for the file containing the script.
 
Old 12-30-2008, 12:33 PM   #2
clvic
Member
 
Registered: Feb 2008
Location: Rome, Italy
Distribution: OpenSuSE 11.x, vectorlinux, slax, Sabayon
Posts: 206
Blog Entries: 2

Rep: Reputation: 45
In bash, the variable "$$" contains the pid of the current bash process, while "$PPID" contains the pid of the parent process, so which one to use depends on how you execute the script. A login shell is not unique in the system, maybe these commands are what you need.

If you don't have execute permissions on a script, say it is /usr/bin/zless, then launch it as "sh /usr/bin/zless". Another way is reading it (cat /usr/bin/zless > /tmp/zless), giving it execute permissions (chmod +x /tmp/zless), and executing it directly (/tmp/zless). Using this second way you don't need to know which is the right interpreter for the script, as the system itself will find it out.
 
Old 12-30-2008, 01:12 PM   #3
jonhanna
Member
 
Registered: Dec 2008
Posts: 31

Original Poster
Rep: Reputation: 15
thanks i really appreciate the help, i will will have to research what some of that is but that is fine because i need to learn, but thanks.
 
Old 12-30-2008, 01:39 PM   #4
arckane
Member
 
Registered: Sep 2005
Location: UK
Distribution: Gentoo/Debian/Ubuntu
Posts: 307

Rep: Reputation: 38
1. If you do 'ps' alone, the first PID listed for BASH should be the one you are using. But as stated, it's
2. As clvic says
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
executing konsole from shell script Meriadoc Linux - Newbie 10 07-10-2009 09:08 AM
Executing a command in Shell Script gjagadish Programming 7 10-15-2007 05:23 AM
Executing a shell script command!! vishamr2000 Programming 4 08-15-2005 01:33 AM
executing shell script on apache nooodles Linux - General 1 06-29-2004 02:51 AM
executing a shell script from C llama_meme Programming 2 04-01-2002 10:10 PM


All times are GMT -5. The time now is 02:35 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration