Problem with path and child shells


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Problem with path and child shells
# 1  
Problem with path and child shells

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

a) Some Unix tools are at $HOME/mytools directory. Make these tools accessible for use from any directory.
b) Make these tools usable from child shells.
c) How to make them readily usable whenever you login to the UNIX shell.

2. Relevant commands, code, scripts, algorithms:

echo, PATH, bash


3. The attempts at a solution (include all code and scripts):

My attempt for a) is PATH=$PATH\: $HOME/mytools
b and c I have noo idea about. Smilie I know what child shells are, but isn't the mytools already accessible by them? For c, does it want me to change the path to mytools??

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

University of Alabama at Birmingham, Birmingham (AL), US, Taofiq, cs333
do not have a link to class
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Don't think you need the backslash there.

PATH=${PATH}:/$HOME/mytools

To make it accessible to child shells, you have to make sure its in the environment:

Code:
export PATH

For C, you have to put it in your ~/.profile or ~/.bashrc or whatever login file your shell uses. See the manual page for your shell.
# 3  
The following should be acceptable answers:

a. This will add mytools for the current shell. At command prompt, type the following and hit "enter": PATH=$HOME/mytools:$PATH

b. This will add mytools for child shells as well. At command prompt, type the following and hit "enter": export PATH=$HOME/mytools:$PATH

c. To make this permanent, so commands in mytools directory are usable upon login to the UNIX shell (bash), just add "export PATH=$HOME/mytools:$PATH" to your .bashrc file. Most .bashrc files already have this statement, so it would just be a matter of modifying it.


The placement within PATH is significant. The shell searches for commands from left to right as you read the directories in PATH. In my example, I've placed mytools before all other directories so it is searched first. I do this for two reasons:
1. I want commands in mytools to be used before a command with the same name that is in another directory. Generally, this is not a problem as I don't intentionally use an existing command name.
2. Even if I don't have duplicate command names, I want my scripts to be found quickly. By listing mytools at the beginning, it is searched first. This may only be saving microseconds or less, but that's the way I want it.

Otherwise, adding mytools at the end of the PATH statement is certainly acceptable.

Hope this helps...
--majickmann
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #359
Difficulty: Medium
The chmod command first appeared in Version 1 AT&T UNIX.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with PATH

Recently I lost a number of changes I made to a program when the SCO Unix system went down. The system "mail" suggested a "vi -r" option that took me back several days. To prevent this in the future, I am trying to create my own vi command: if then cp -p $1 $1.bak fi /usr/bin/vi $* if ... (5 Replies)
Discussion started by: wbport
5 Replies

2. Shell Programming and Scripting

Moving files from parent path to multiple child path using bash in efficient way

Hi All, Can you please provide some pointers to move files from Base path to multiple paths in efficient way.Folder Structure is already created. /Path/AdminUser/User1/1111/Reports/aaa.txt to /Path/User1/1111/Reports/aaa.txt /Path/AdminUser/User1/2222/Reports/bbb.txt to... (6 Replies)
Discussion started by: karthikgv417
6 Replies

3. Homework & Coursework Questions

Need help with deleting childīs parent and child subprocess

1. The problem statement, all variables and given/known data: I need to make an program that in a loop creates one parent and five children with fork(). The problem i'm trying to solve is how to delete the parent and child of the childīs process. 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: WhiteFace
0 Replies

4. UNIX for Dummies Questions & Answers

PATH Setting for all shells of a user

How can I modify the path variable of a particular user in all shells? I searched in this forum and as per the advice in some threads created a new file .profile in $HOME directory with the new PATH, but it did not work. (5 Replies)
Discussion started by: JoyceBabu
5 Replies

5. Infrastructure Monitoring

Problem with PATH

On one of the machines at work, we had Net-SNMP 5.2.3 installed, and I wanted to upgrade that to 5.4.2.1. So I downloaded the tar file, extracted it, did the configure, make, make test, make install, and everything worked. All the executable files (like snmpget, snmpset, snmpwalk) got copied to... (1 Reply)
Discussion started by: sllinux
1 Replies

6. UNIX for Advanced & Expert Users

how to make a parent wait on a child shells running in background?

Hi I have a shell script A which calls another 10 shell scripts which run in background. How do i make the parent script wait for the child scripts complete, or in other words, i must be able to do a grep of parent script to find out if the child scripts are still running. My Code: ... (1 Reply)
Discussion started by: albertashish
1 Replies

7. UNIX for Advanced & Expert Users

path problem

Hi i am writing a script containing processing commands which are reside in /opt/terascan/bin dir. if i run the script from command prompt it is working fine. but in crontab it is not working. if i give env command from command prompt it is showing /opt/terascan/bin dir in PATH variable. ... (10 Replies)
Discussion started by: rajan_ka1
10 Replies

8. Shell Programming and Scripting

path problem

hi , i have written csh script i am unable to set PATH variable in my script. my script is like this ===================================== # ! /bin/csh -f setenv PATH "$PATH:/opt/terascan/bin" ls -l > list lspass > pas peekauto > schedule \ num_days = 1 \ exit 0... (1 Reply)
Discussion started by: rajan_ka1
1 Replies

9. UNIX for Dummies Questions & Answers

cc path problem - no acceptable path found

Hello everyone, I'm a unix noob. I have a powerbook running mac os x 10.4 and for one of my classes I need to install the latest version of php (5.0.5). I'm following the instructions at http://developer.apple.com/internet/opensource/php.html to install but I've run into a problem. The... (2 Replies)
Discussion started by: kendokendokendo
2 Replies

10. IP Networking

child process problem

please do answer it is urgent can any body tell me how can i find whether the child process has been killed or not in a program (1 Reply)
Discussion started by: ramneek
1 Replies

Featured Tech Videos