shanenin
-
Content Count
3752 -
Joined
-
Last visited
Content Type
Profiles
Forums
Calendar
Posts posted by shanenin
-
-
so \c must not be supported in bash, is that what you are saying?
-
Among other things.
I found one of those other things.
#!/bin/bash
RESPONSE=
while [ -z "$RESPONSE" ];
do
echo "Enter the name of the directory where your files are located:\c "
read RESPONSE
if [ ! -d "$RESPONSE" ]; then
echo "ERROR: please enter a directory pathname."
RESPONSE=
fi
doneaccording to the book, my output should be
Enter the name of the directory where your files are located:
but I am getting
Enter the name of the directory where your files are located:\c
I thought that the "\" worked as quoting. So that would disable a special character? the letter "c" does not seem to be a special character
-
what is -lt (is that like NE or !=)
it means "less then"
were you asking that?
-
thanks. I can see debugging programs being a huge undertaking. I have trouble finding them with just three lines of code
-
I think i have copied this script exactly as printed in my book, but it keeps failing
shane@mainbox shane $ cat scripts/loop
#!/bin/bash
x=0
while [ $x -lt 10 ]
do
echo $x
x=`echo "$X + 1" | bc`
done
shane@mainbox shane $ ./scripts/loop
0
(standard_in) 1: parse error
./scripts/loop: line 3: [: -lt: unary operator expected -
is that meant to check if that is a set variable?Among other things.
sorry you already answered that(I missed it)
I am sure you already knew these are equal expressions
test -z $var
[ -z $var ]
-
would
test -z $VAR
be mainly used to check if a variable is already set? .
-
is that meant to check if that is a set variable?
In my mind these should be outputting 0 for the first one but 1 for the second one.
shane@mainbox shane $ gg=""; [ -z $gg ]; echo $?
0
shane@mainbox shane $ gg=""; [ -n $gg ]; echo $?
0 -
I am tring to understand what a "zero lenght" or non zero length string" string would be. That seems to be a string with no characters, but then it would be nothing
example
[ -n $TEST ]
[ -z $VAR ] -
I have heard good stuff about ubuntu, I would say go for it.
-
wow that set command is handy. Now I am able to kind of see what is happening.
I thought that $DATE would change depnding on what 'one' was set to. It does but 'one' has to be set before doing
DATE=${one:-three}
I was setting 'one' after using the above command. Then It has no effect one the variable DATE.
So long as 'one' is not set before using DATE=${one:-three} three is substituted.
-
Is ther a way to show(list) all set and/or exported varibles in a bash shell?
edit added later//
I have a substitution question. Lets say I do this
shane@mainbox shane $ DATE=${one:-two}
shane@mainbox shane $ echo $DATE
twoHow would I get it to echo the value one?
-
I am happy to have reinstalled linux. I started installing gentoo yesterday, and have a working system, with gnome, this morning. I guess I feel more at home with linux.
I enjoyed my BSD experience, but really missed linux(on my main workstation). BSD is a great system, but it seems to be just a little less polished(for the desktop) then linux. In all honesty if I took the time, I could probably have worked all of the kinks out of my bsd system. Somethings were surprisingly easy on BSD: If I remember correctly installing the nvidia 3d drivers were just one simple command. Sound was also as easy as loading one module, I had a common via chipset, so that helped. Ports was great, every package I wanted, installed with one simple command. The ports tree is very updated, I got the newest of everything, including gnome-2.8.
If I ever plan on building a web server, I will probably go the bsd route.
BSD is refering to FreeBSD-5.2 (I think that is the version I had)
-
not to side track your thread, I noticed you refernced the LFS book. That is a great place of knowledge. I forgot how to install grub, I am so used to gentoos ebuilds doing it for me. I first went to grubs homepage, but could not find the needed info. The LFS book told you exactly what needs to be done; it was laid out in a very simple easy to follow method.
-
I see ;-)
none the less, I will try to be more POSIX complient.
-
if that is true, why does it run on my bsd box which is using true /bin/sh?
-
for portability, I used #!/bin/sh instead of #!/bin/bash . This way the script shuld run on a bsd box that does not have bash installed. Linux just makes a link form /bin/sh to /bin/bash, but......
I got my script to work on my linux box by changeing #!/bin/sh to #!/bin/bash , how could that be? Why should that make any difference?
-
I wrote this revised script on my bsd workstation. It seems to run well
#!/bin/sh
check-nfs ()
{
echo "checking"
mount | grep 192.168.1 > /dev/null
if [ "$?" = 0 ]
then
echo "NFS is mounted"
return 0
else
echo "NFS is not mounted"
return 1
fi
}
mount-nfs ()
{
echo "mounting NFS"
mount -t nfs 192.168.1.104:/mnt/media /home/shane/freevo
}
run-unison ()
{
echo "preparing to run unison"
/usr/local/bin/unison -version
exit 0
}
echo "NFS needs to be mounted before sycing can begin"
check-nfs
if [ "$?" = 0 ]
then
run-unison
else
mount-nfs
check-nfs
fi
if [ "$?" = 0 ]
then
run-unison
else
echo "NFS failed to mount. exiting"
fithe problem comes when I port it over to my linux freevo box. I am getting this error
freevo2 root # freevosync
/usr/local/bin/freevosync: line 15: `check-nfs': not a valid identifier -
return was what I was looking for, Thanks :-) I originally tried to use some other ways that did not work. I will give you guys something to chuckle at
here are some failed attemps:
check-nfs ()
{
echo "checking"
mount | grep 192.168.1 > /dev/null
if [ "$?" = 0 ]
then
echo "NFS is mounted"
exit 0 #this gave me the correct return, but had the negative effect of stoping my script
else
echo "NFS is not mounted"
exit 1
fi
}I also tried this, I was just reaching for anything that might work ;-)
check-nfs ()
{
echo "checking"
mount | grep 192.168.1 > /dev/null
if [ "$?" = 0 ]
then
echo "NFS is mounted"
$?=0
else
echo "NFS is not mounted"
$?=1
fi
} -
I want to use this function in my bash script
check-nfs ()
{
echo "checking"
mount | grep 192.168.1 > /dev/null
if [ "$?" = 0 ]
then
echo "NFS is mounted"
else
echo "NFS is not mounted"
fi
}depending on the output either "NFS is mounted" or "NFS is not mounted" how could i use that output as a condition in an other if else statement? Sorry if this is not clear.
-
you should check to see if nfs mouted again after mounting .. that way no need to do it before runnnig the command..
that is what I originally was trying to do(originally I was using a function), but things were not flowing correctly. The more I tried to fix it, the more ugly it got. So I scrapped everything and started fresh, and came out with the code listed above.
-
this line produces output to my shell, which I do not want. Is there a way to keep this line from making output
mount | grep 192.168.1
edit added later/
I just piped it like this, this seems like an ok solution
mount | grep 192.168.1 | if [ "$?" != 0 ];
-
I decided to make a script that would mount my nfs share before running unison. This way I wont ever forget to mount it. I think that would screw up my syncing. Thanks for the help(iccaros and jcl), this is my first attempt at programming(term used very loosely)
#!/bin/sh
mount | grep 192.168.1
if [ "$?" != 0 ];
then
echo "mounting nfs share"
mount_nfs 192.168.1.104:/mnt/media /home/shane/freevo
else
echo "nfs already mounted, proceeding to sync your servers"
fi
mount | grep 192.168.1
if [ "$?" = 0 ]
then
echo "preparing to run unison"
# the following line gives the command to sync my two servers
/usr/bin/unison /home/shane/freevo /mnt/media
else
echo "nfs failed to mount. exiting"
fi -
this program, unison, is really cool. It can sync servers on you local system using NFS. It can also sync servers remotely by tunneling using ssh. It also works across platforms window to linux. Another neat feature unlike rysync, you can make changes to either server(not the master server only) then the changes will get updated to the other server.
I am still working out some bugs, but I am pretty sure it will work like it is supposed to.
Come On.....admit It!
in Open Chat
Posted · Edited by shanenin
1. I have been a chronic drug addict since about age 14(daily pot smoker), I spent the years of age 21 - 27 shooting meth daily. My drug addiction is not really a secret, It is just part of me. I have never hid it, infact I enjoy shocking people with it I have been sober with the help of AA and God for over 5 years.
2. I depend on God for everything. With out my daily prayers and time spent with god, I would still be sticking a needle in my arm. I need God in my life. I used to be a hardened atheist(scientific type). Faced with the fact of dying by my own hands(slowly with meth, could not stop) or depending on a higher power(thats what AA is all about), I chose faith
3. I Talk to my self alot I sometimes wonder what my wife thinks of me. I am scared my kids are going to start talking to them selfs. My grandapa, who was a very inteligent, well spoken man, always was mumbling under his breath. It must be geneitc.