-   Programming (
-   -   shell script how to execute (

x2000koh 07-28-2003 10:59 PM

shell script how to execute
Hi all,
I am beginner of shell script. i have created my script as following step.

1) I have created The simple content is as follow.

date ; who ;

2) Make it excutable
chmod a+x

3) run the program

Question :
when run program ( it appear the following. Command not found

Appreciate if anyone can help.

coolman0stress 07-28-2003 11:03 PM

try ./

x2000koh 07-29-2003 12:27 AM

login to department folder
Thanks coolman0stress,
1) it is working now. I am learning shell script, appreciate your reply.

2) Appreciate if you can help.
The objective : The users can only see his department folder when he login.

In my linux server, I have created 2 departments (acct and mkt department). In acct department, I have (useradd) acctuser1 and acctuser2. In mkt department, I have (useradd) mktuser1 and mktuser2.

In my (/home/AusDepts) is a directory contain all the department folders.(/home/AusDepts/acct) and (/home/AusDepts/mkt).

When acctuser1 login, a soft link (ln -s source target) will be created in his /home/acctuser1 directory link to /home/AusDepts/acct). That's mean when acct user login he can see his accounting department folder. Whereas mktuser login he can see his marketing department folder.

How can I do this ? In my /home/acctuser1/.bash_profile I have added :

ln -s /home/AusDepts/acct acct

But it doesn't link once. First is say the target directory doesn't exit. when I created the target manually, It provide endless link ?

Appreciate if you can advise or provide alternation suggestion to the solution.

Thanks and regards,

DIYLinux 07-29-2003 04:51 AM

Set it up statically, that is make the link only once. Note that only the root can symlink directories, because of security implications.

Perhaps I dont understand what you try to do. Since every user has its own home directory, it should be easy to create a link in his/her home dir to the department dir. If there are (will be) many users, consider creating a script to create. This script should create the /etc/passwd entries (calling adduser or useradd) and create and fill the home directory.

x2000koh 07-29-2003 05:32 AM

Actually I am working on NIS server and client. That'w why I need to symbolic link.

I manage to write a shell script to evaluate the group ID then do a symbolic link to the user home directory.

Now I need the .bash_profile to call a program

how can I do that ?


DIYLinux 07-29-2003 07:00 AM

.bash_profile is an ordinary shell script. You can call like any other executable. Example (provided is placed in a directory that is in $PATH)

# call bash builtin (there is also a standalone executable, do help set)
echo "The path is $PATH"
# call the cat program
cat /etc/passwd
# same, with explicit path
/bin/cat /etc/passwd
# now for

Take care of these points:
- The directory in which is placed should be in the path
- It should be executable by whoevere runs .bash_profile (the owner of the home directory in this case). Do a ls -l, and possibly a chmod.
- Beware of other programs called, whose directories are also in $PATH. Use the which command to check.

coolman0stress 07-29-2003 04:20 PM

Sorry x2000koh, but i know very little about shell scripting. I just knew the answer to your original question because i encountered it before (it happened because the current directory you worked in wasn't part of the search path, by adding ./ you specify where the file is - you can also directly add your current dir to the path too instead).

Anyway, good luck :)

All times are GMT -5. The time now is 02:46 PM.