One-liner ping test while: Expression Syntax.
-
Hi
i need a one liner ping test "script" but the it doest work under pfsense 2.0.1
while ! ping -c1 www.pfsense.org; do sleep 1; done
gives me on the shell out:
while: Expression Syntax.
what is missing on pfsense to get it to work?
under FreeBSD9 it works ;)greetings ren22
-
pfSense default shell is tcsh. Presumably you are using a different shell in FreeBSD. The FreeBSD man page for tcsh give a different syntax for the while command than appears in your example.
-
really ?
my FreeBSD9 Desktop:
$ uname -a
FreeBSD nas 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:15:25 UTC 2012 root@obrian.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386$ echo $SHELL
/bin/shon Pfsense2.0.1:
uname -a
FreeBSD pfsense.localdomain 8.1-RELEASE-p6 FreeBSD 8.1-RELEASE-p6 #1: Wed Dec 14 10:20:20 EST 2011 root@FreeBSD_8.0_pfSense_2.0-snaps.pfsense.org:/usr/obj.pfSense/usr/pfSensesrc/src/sys/pfSense_wrap_vga.8.i386 i386echo $SHELL
/bin/shso i am a bit confused xD
anyway someone has a damn good hint for me ?
-
Shell in pfSense may depend on the context. On a ssh session to a pfSense 2.0.1 system and login as admin I see:```
[2.0.1-RELEASE][admin@pfsense.example.org]/root(27): echo $SHELL
/etc/rc.initial
[2.0.1-RELEASE][admin@pfsense.example.org]/root(28):and /etc/rc.initial starts /bin/tcsh if option 8 (Shell) is selected.
-
;)
i am running the pfsense as embedded with VGA enabled, may thats why you have the different output ?
i dont know why you have different output and i tried some different one-liners on pfSense2.0.1 allmost all of them gives my an
error like this :Pfsense2.0.1:
[2.0.1-RELEASE][root@pfsense.localdomain]/root(17): if test -d foo ; then echo yup ; else echo nope ; fi
if: Expression Syntax.FreeBSD9 as unprivileged user:
$ if test -d foo ; then echo yup ; else echo nope ; fi
nope
$i dont know what i am doing wrong on the other FreeBSD system the one-liners works …
i am really confused xD
-
-
thanks a lot wallabybob that was one step ahead :) but not the resolution :'(
i dont know why but i use this one-liner now with "shellcmd"
while ! ping -c1 www.pfsense.org; do sleep 1; done && date | echo 'the host is back!' >> /tmp/pingtest.txt
and it works :) :) :) BUT NOT ON A SHELL PROMPT ….
so i use this now :-\
-
$SHELL is not necessarily your active shell. To find your running shell, do:
[2.0-RELEASE][admin@pfsense.wired.local]/root(72): echo $0
/bin/tcsh
I believe $SHELL is your default shell, which may not be what is being invoked at that time.
I'm not a BSD expert by any means either, but on every other single *NIX system I've been on, /bin/sh is the bourne shell which is definitely not tcsh.
-Lou