Re: Bug with tcsh? : if evaluating true instead of false
I appreciate the help thanks! Sure, I'll send the script to you in an individual email instead of as an attachement to the list. Should anyone on the list want a copy, just drop me an email. I'd appreciate the script though, definitely, as any resource I have to learn all Unix script languages properly will only help in my becoming a better Unix admin as well as script more common tasks to help make my life a bit easier. When I've started to write shell scripts, I read a nice book which covered sh, csh and ksh with lots of examples. That was the first edition, but it's now in it's fourth edition and now have coverage of bash and tcsh plus you get info on sed awk. UNIX Shells By Example, Ellie Quigley, Prentice Hall PTR; 4th edition (Sep 24 2004), 1200 pages, ISBN: 013147572 On amazon.ca: http://www.amazon.ca/UNIX-Shells-Example-Ellie-Quigley/dp/013147572X/sr=1-1/qid=1161886975/ref=sr_1_1/701-2925611-9451566?ie=UTF8s=books Otherwise, you can always Google around for unix shell script and such. There are a lot of sites on the topic. I would select one from a University. Have fun! David -- David Robillard UNIX systems administrator Oracle DBA CISSP, RHCE Sun Certified Security Administrator Montreal: +1 514 966 0122 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Bug with tcsh? : if evaluating true instead of false
On Thu, Oct 26, 2006 at 02:36:06PM -0400, David Robillard wrote: I appreciate the help thanks! Sure, I'll send the script to you in an individual email instead of as an attachement to the list. Should anyone on the list want a copy, just drop me an email. I'd appreciate the script though, definitely, as any resource I have to learn all Unix script languages properly will only help in my becoming a better Unix admin as well as script more common tasks to help make my life a bit easier. When I've started to write shell scripts, I read a nice book which covered sh, csh and ksh with lots of examples. That was the first edition, but it's now in it's fourth edition and now have coverage of bash and tcsh plus you get info on sed awk. UNIX Shells By Example, Ellie Quigley, Prentice Hall PTR; 4th edition (Sep 24 2004), 1200 pages, ISBN: 013147572 On amazon.ca: http://www.amazon.ca/UNIX-Shells-Example-Ellie-Quigley/dp/013147572X/sr=1-1/qid=1161886975/ref=sr_1_1/701-2925611-9451566?ie=UTF8s=books Otherwise, you can always Google around for unix shell script and such. There are a lot of sites on the topic. I would select one from a University. Have fun! David -- David Robillard UNIX systems administrator Oracle DBA CISSP, RHCE Sun Certified Security Administrator Montreal: +1 514 966 0122 I inherited an older edition of UNIX Shell by Example and agree it's a good book. I'd also recommend O'Reilly's Classic Shell Scripting (http://www.oreilly.com/catalog/shellsrptg/). I probably shouldn't encourage this sort of thing, but you can find the entire O'Reilly CD Bookshelf on the web if you want to sample the books before buying. -Damian ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Bug with tcsh? : if evaluating true instead of false
On 10/27/06, Damian Wiest [EMAIL PROTECTED] wrote: I inherited an older edition of UNIX Shell by Example and agree it's a good book. I'd also recommend O'Reilly's Classic Shell Scripting (http://www.oreilly.com/catalog/shellsrptg/). I probably shouldn't encourage this sort of thing, but you can find the entire O'Reilly CD Bookshelf on the web if you want to sample the books before buying. You can also check out the Shell Scripting mailing list at moongroup.com: List-Archive: http://moongroup.com/pipermail/shell.scripting List-Post: mailto:[EMAIL PROTECTED] List-Help: mailto:[EMAIL PROTECTED] List-Subscribe: http://moongroup.com/mailman/listinfo/shell.scripting, mailto:[EMAIL PROTECTED] Has some knowledgeable and helpful people on it, and it's fairly low-traffic too. -- Juha http://www.geekzone.co.nz/juha ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Bug with tcsh? : if evaluating true instead of false
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ok, so I tried to make a simple script to add users so I wouldn't have to type in groups/pw over and over again... the problem is that it's not behaving like it should =o. Script: #!/bin/tcsh -x # if ( ( $# != 0 ) ) { set GROUPS=; set USER=; if( ( $# == 2 ) ) { set USER=$1; set GROUPS=$0; switch($0) case -v: set GROUPS=-G vip; breaksw case -w: set GROUPS=-G vip,wheel; breaksw default: echo bad argument(s) specified!; exit(1); endsw } else if($# == 1) { set USER=$0; } else { echo bad # of args; exiting..; } `pw add user -N -d /home/$USER -s /usr/local/bin/bash $GROUPS $USER mkdir /home/$USER ln -s /home/dud.bash_login /home/$USER/.bash_login`; } else { print Usage [-r|-v|-w] username } Output: [EMAIL PROTECTED] ~]# ./mkuser if ( ( 0 != 0 ) ) { set GROUPS= set USER= if ( ( 0 == 2 ) ) { set USER= set GROUPS=./mkuser switch ( ./mkuser ) echo bad argument(s) specified! bad argument(s) specified! exit ( 1 ) Basically it should drop out at the first if statement due to 0 != 0 being true and go straight to the else block, but it's falling through to the switch statement. Any ideas? Also.. [EMAIL PROTECTED] /home/gcooper]# tcsh --version tcsh 6.14.00 (Astron) 2005-03-25 (i386-intel-FreeBSD) options wide,nls,dl,al,kan,rh,color,filec Thanks! - -Garrett -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFPwXc6CkrZkzMC68RAo4sAJ9LOcJ6xnjTo2pWF8W6nOjqXqjfmACeP9OC WQWFzBpbKca+kkdT1APlo3k= =G6sT -END PGP SIGNATURE- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Bug with tcsh? : if evaluating true instead of false
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Garrett Cooper wrote: Ok, so I tried to make a simple script to add users so I wouldn't have to type in groups/pw over and over again... the problem is that it's not behaving like it should =o. Script: #!/bin/tcsh -x # if ( ( $# != 0 ) ) { set GROUPS=; set USER=; if( ( $# == 2 ) ) { set USER=$1; set GROUPS=$0; switch($0) case -v: set GROUPS=-G vip; breaksw case -w: set GROUPS=-G vip,wheel; breaksw default: echo bad argument(s) specified!; exit(1); endsw } else if($# == 1) { set USER=$0; } else { echo bad # of args; exiting..; } `pw add user -N -d /home/$USER -s /usr/local/bin/bash $GROUPS $USER mkdir /home/$USER ln -s /home/dud.bash_login /home/$USER/.bash_login`; } else { print Usage [-r|-v|-w] username } Output: [EMAIL PROTECTED] ~]# ./mkuser if ( ( 0 != 0 ) ) { set GROUPS= set USER= if ( ( 0 == 2 ) ) { set USER= set GROUPS=./mkuser switch ( ./mkuser ) echo bad argument(s) specified! bad argument(s) specified! exit ( 1 ) Basically it should drop out at the first if statement due to 0 != 0 being true and go straight to the else block, but it's falling through to the switch statement. Any ideas? Also.. [EMAIL PROTECTED] /home/gcooper]# tcsh --version tcsh 6.14.00 (Astron) 2005-03-25 (i386-intel-FreeBSD) options wide,nls,dl,al,kan,rh,color,filec Thanks! -Garrett Duh... tcsh syntax != C/C++ or Java syntax. Silly me... lol. - -Garrett -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFPyQr6CkrZkzMC68RApumAJ9hl365xnqYknflDGr2Cc7O/UClnwCeN7Ih KsVQzm0ySuW3bSGe7cCgltQ= =MZO5 -END PGP SIGNATURE- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Bug with tcsh? : if evaluating true instead of false
Ok, so I tried to make a simple script to add users so I wouldn't have to type in groups/pw over and over again... the problem is that it's not behaving like it should =o. [ ...8... Removed a bunch of lines ...8... ] IMHO, if you need to script something, use /bin/sh. It's the standard shell interpreter on all flavors of UNIX and Linux (except maybe MacOS X). All of the rc scripts are written with it. So why bother with another shell? Here's an interesting read on the topic: http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ BTW, Tom Christiansen who wrote this is co-author of Programming Perl from O'Reilly. So, Garret, if you need help with this, I have a /bin/sh version of the script you're trying to do. Just drop me a line and I'll send it to you. Just my two cents :) David -- David Robillard UNIX systems administrator Oracle DBA CISSP, RHCE Sun Certified Security Administrator Montreal: +1 514 966 0122 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Bug with tcsh? : if evaluating true instead of false
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David Robillard wrote: Ok, so I tried to make a simple script to add users so I wouldn't have to type in groups/pw over and over again... the problem is that it's not behaving like it should =o. [ ...8... Removed a bunch of lines ...8... ] IMHO, if you need to script something, use /bin/sh. It's the standard shell interpreter on all flavors of UNIX and Linux (except maybe MacOS X). All of the rc scripts are written with it. So why bother with another shell? Here's an interesting read on the topic: http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ BTW, Tom Christiansen who wrote this is co-author of Programming Perl from O'Reilly. So, Garret, if you need help with this, I have a /bin/sh version of the script you're trying to do. Just drop me a line and I'll send it to you. Just my two cents :) David I appreciate the help thanks! I usually do stuff in either bash or csh, depending on the level of difficulty, but try to use tcsh for all FreeBSD scripts on my system since tcsh is included as a part of the base system. Plus, I do like tcsh better in some ways because the syntax is similar to C/C++ and Java, but as you saw if I get in a programming funk with either of the 3 beforementioned languages, it's fun remembering language semantics sometimes :). I'd appreciate the script though, definitely, as any resource I have to learn all Unix script languages properly will only help in my becoming a better Unix admin as well as script more common tasks to help make my life a bit easier. Thanks! - -Garrett -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFP7e66CkrZkzMC68RAhsUAJ93jj0Qx1aFcVPLe0WT9xGnSiaEIQCdFiq1 D3AaQo5y5wv9Pcn8G4WbYQM= =LcA7 -END PGP SIGNATURE- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Bug with tcsh? : if evaluating true instead of false
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David Robillard wrote: Ok, so I tried to make a simple script to add users so I wouldn't have to type in groups/pw over and over again... the problem is that it's not behaving like it should =o. [ ...8... Removed a bunch of lines ...8... ] IMHO, if you need to script something, use /bin/sh. It's the standard shell interpreter on all flavors of UNIX and Linux (except maybe MacOS X). All of the rc scripts are written with it. So why bother with another shell? Here's an interesting read on the topic: http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ BTW, Tom Christiansen who wrote this is co-author of Programming Perl from O'Reilly. So, Garret, if you need help with this, I have a /bin/sh version of the script you're trying to do. Just drop me a line and I'll send it to you. Just my two cents :) David Also, another thing is that a lot of what I was trying to do was not only add user classes, but also restrict users from accessing my server unless they were in the wheel group. Got that done with /etc/login.access by adding: - -ALL except wheel:ALL Now since I mentioned it though I was wondering, does this create issues for secondary daemon accounts (www, mysql, etc)? Thanks! - -Garrett -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFP7jj6CkrZkzMC68RAuldAKCDmbEv4P94VUeIrfohLKIkcY1QlQCeKmz2 OCCVA0n6utl0J8AxoIxMWLA= =Nufx -END PGP SIGNATURE- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]