Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-30-2008, 09:12 AM   #1
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, 11:33 AM   #2
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, 12:12 PM   #3
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, 12:39 PM   #4
Registered: Sep 2005
Location: UK
Distribution: Gentoo/Debian/Ubuntu
Posts: 308

Rep: Reputation: 39
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


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

All times are GMT -5. The time now is 10:55 AM.

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