Re: how to grep error messages

2009-06-29 Thread Boyd Stephen Smith Jr.
In <20090628141815.gm2...@pear.tzafrir.org.il>, Tzafrir Cohen wrote: >On Sun, Jun 28, 2009 at 11:42:58AM +0200, Michelle Konzack wrote: >> But I would prefer something like: >> >> if [ $(cd "$1") -ne 0 ] >> then echo "badbadbad" ; exit 1 >> fi > >Note that this runs the 'cd' command

Re: how to grep error messages

2009-06-29 Thread Boyd Stephen Smith Jr.
In <20090628094255.ga12...@freenet.de>, Michelle Konzack wrote: >Am 2009-06-28 11:39:55, schrieb Soren Orel: >> I can /dev/null the error messages like: >> >> cd "$1" 2> /dev/null >> >> e.g.: I get error If "$1" has spaces in it >> >> Ok, but how can I grep the error message? I tried: >> >> if cd "

Re: how to grep error messages

2009-06-28 Thread Soren Orel
final solution: if ! cd "$1"; then echo "error"; exit 1; fi thank you!

Re: how to grep error messages

2009-06-28 Thread Osamu Aoki
Hi, On Sun, Jun 28, 2009 at 11:39:55AM +0200, Soren Orel wrote: > I can /dev/null the error messages like: > > cd "$1" 2> /dev/null 2> will redirect to a file /dev/null > e.g.: I get error If "$1" has spaces in it > > Ok, but how can I grep the error message? I tried: > > if cd "$1" 2> grep

Re: how to grep error messages

2009-06-28 Thread Tzafrir Cohen
On Sun, Jun 28, 2009 at 11:42:58AM +0200, Michelle Konzack wrote: > But I would prefer something like: > > if [ $(cd "$1") -ne 0 ] > then echo "badbadbad" ; exit 1 > fi Note that this runs the 'cd' command in a subdirectory, and thus it has no effect on the parent process. And t

Re: how to grep error messages

2009-06-28 Thread Soren Orel
$ sh script.sh /home/user/Desktop/some existing dir with spaces script.sh: line 2: cd: /home/gbor/Desktop/some: No such file or directory script.sh: line 2: [: -ne: unary operator expected $ cat script.sh #!/bin/bash if [ $(cd "$1") -ne 0 ] then echo "badbadbad" ; exit 1 fi I just want to make m

Re: how to grep error messages

2009-06-28 Thread Michelle Konzack
Am 2009-06-28 11:48:54, schrieb me: > hehe, answered at the same time :D =8http://counter.li.org/ # Debian GNU/Linux Consultant # Michelle Konzack c/o Shared Office KabelBW ICQ #328449886 +49/177/9351947Blumenstasse 2 MSN LinuxMichi +33/6/

Re: how to grep error messages

2009-06-28 Thread me
hehe, answered at the same time :D 2009/6/28 me > Hi, > > how about: > > > cd "$1" > > if [ $? != '0' ]; then > echo "damn." > exit; > fi > > > greetings, > vitaminx > > > 2009/6/28 Soren Orel > > I can /dev/null the error messages like: >> >> cd "$1" 2> /dev/null >> >> e.g.: I get error If

Re: how to grep error messages

2009-06-28 Thread me
Hi, how about: cd "$1" if [ $? != '0' ]; then echo "damn." exit; fi greetings, vitaminx 2009/6/28 Soren Orel > I can /dev/null the error messages like: > > cd "$1" 2> /dev/null > > e.g.: I get error If "$1" has spaces in it > > Ok, but how can I grep the error message? I tried: > > if

Re: how to grep error messages

2009-06-28 Thread Michelle Konzack
Am 2009-06-28 11:39:55, schrieb Soren Orel: > I can /dev/null the error messages like: > > cd "$1" 2> /dev/null > > e.g.: I get error If "$1" has spaces in it > > Ok, but how can I grep the error message? I tried: > > if cd "$1" 2> grep -i "No such file or directory"; then echo "badbadbad"; > e

how to grep error messages

2009-06-28 Thread Soren Orel
I can /dev/null the error messages like: cd "$1" 2> /dev/null e.g.: I get error If "$1" has spaces in it Ok, but how can I grep the error message? I tried: if cd "$1" 2> grep -i "No such file or directory"; then echo "badbadbad"; exit; fi But it doesn't work :S thank you!