Results 1 to 5 of 5
I am trying to write a bash script that checks for a directory and if the directory is not there creates it. I have everything written but I have no ...
- 05-12-2004 #1Just Joined!
- Join Date
- May 2004
- Posts
- 2
bash question
I am trying to write a bash script that checks for a directory and if the directory is not there creates it. I have everything written but I have no idea how to have bash check for a directory.
example,
if [/Library/Admin Is not there]; then
mkdir /Library/Admin
fi
can't figure out the part between the [].
Thanks. for the help.
- 05-12-2004 #2That will do it with a command line arg. for the directory that you want to check.Code:
#!/bin/sh if [[ -e $1 ]] then echo "Directory Exists." else mkdir $1 echo "Directory Created." fi
"Time is an illusion. Lunchtime, doubly so."
~Douglas Adams, The Hitchhiker's Guide to the Galaxy
- 05-12-2004 #3Just Joined!
- Join Date
- May 2004
- Posts
- 2
logging in user
I have another bash script that runs at login and is supposed to get the username of the person that is logging in, but it doesn't do it. However, if I run the script from the terminal after I have logged in it gets the username of the person logged in.
here is what I use to get the username
LOGINNAME=`/usr/bin/who | /usr/bin/grep console | /usr/bin/awk '{ print $1 }'`
How can I get the username as they are logging in and not after they have logged in?
Thanks.
- 05-17-2004 #4Linux Guru
- Join Date
- Mar 2003
- Location
- Wisconsin
- Posts
- 1,907
The problem is you're running your script before you're actually logged in.
Try putting the call to your script as close to the end as possible in the .bash_profile file. If that doesn't work, try it in the .bashrc file...
I know there's a gui equivilent to .bash_profile, like one of those rc files. I'll see if I can't find it.
Or you might try a sleep command. I'm not sure if that would make your entire login pause until the command is finished executing or not. If it doent, you can make it sleep for like a minute or two until the login process is finished.
JeremyRegistered Linux user #346571
"All The Dude ever wanted was his rug back" - The Dude
- 05-19-2004 #5


Reply With Quote
