• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

One-liner ping test while: Expression Syntax.

Scheduled Pinned Locked Moved General pfSense Questions
8 Posts 3 Posters 3.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R
    ren22
    last edited by Jan 3, 2013, 11:04 AM

    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

    1 Reply Last reply Reply Quote 0
    • W
      wallabybob
      last edited by Jan 3, 2013, 11:28 AM

      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.

      1 Reply Last reply Reply Quote 0
      • R
        ren22
        last edited by Jan 3, 2013, 7:56 PM Jan 3, 2013, 7:49 PM

        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/sh

        on 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  i386

        echo $SHELL
        /bin/sh

        so i am a bit confused xD

        anyway someone has a damn good hint for me ?

        1 Reply Last reply Reply Quote 0
        • W
          wallabybob
          last edited by Jan 3, 2013, 8:21 PM

          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.
          1 Reply Last reply Reply Quote 0
          • R
            ren22
            last edited by Jan 3, 2013, 8:35 PM Jan 3, 2013, 8:32 PM

            ;)

            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

            1 Reply Last reply Reply Quote 0
            • W
              wallabybob
              last edited by Jan 3, 2013, 8:44 PM

              Does```
              [2.0.1-RELEASE][admin@pfsense.example.org]/root(35): if test -d foo ; then echo yup ; else echo nope ; fi
              if: Expression Syntax.
              [2.0.1-RELEASE][admin@pfsense.example.org]/root(36): /bin/sh

              if test -d foo ; then echo yup ; else echo nope ; fi

              nope

              1 Reply Last reply Reply Quote 0
              • R
                ren22
                last edited by Jan 3, 2013, 9:12 PM

                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  :-\

                1 Reply Last reply Reply Quote 0
                • L
                  loupalladino
                  last edited by Jan 4, 2013, 1:02 AM

                  $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

                  1 Reply Last reply Reply Quote 0
                  8 out of 8
                  • First post
                    8/8
                    Last post
                  Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                    This community forum collects and processes your personal information.
                    consent.not_received