1 Reply Latest reply on Mar 30, 2011 8:46 PM by Barry McQuillan

    Getting shell variable into perl command

      hi all,


      I am looking for a method to delete an IP address from a hosts file.

      I can't seem to get my DHCPIP variable to work from inside the blcli session.


      In SH, BASH I can use:


      export DHCPIP

      perl -ni -e 'print unless /($ENV{DHCPIP})/' hosts


      If I use a blcli session

      fails with:

      u-pr-065% perl -ni -e 'print unless /($ENV{DHCPIP})/' hosts

      nsh: command not found: perl


      Steps were:

      wlgl-05760% blcli_connect


      wlgl-05760% cd //u-pr-065/var/tmp


      u-pr-065% cat hosts


      # hosts         This file describes a number of hostname-to-address

      #               mappings for the TCP/IP subsystem.  It is mostly

      #               used at boot time, when no name servers are running.

      #               On small systems, this file can be used instead of a

      #               "named" name server.

      # Syntax:


      # IP-Address  Full-Qualified-Hostname  Short-Hostname




      # special IPv6 addresses

      ::1             localhost ipv6-localhost ipv6-loopback


      fe00::0         ipv6-localnet


      ff00::0         ipv6-mcastprefix

      ff02::1         ipv6-allnodes

      ff02::2         ipv6-allrouters

      ff02::3         ipv6-allhosts


      u-pr-065% DHCPIP=""

      u-pr-065% export DHCPIP

      u-pr-065% perl -ni -e 'print unless /($ENV{DHCPIP})/' hosts

      nsh: command not found: perl


      If  I use "nexec -e"

      I end up with a blank hosts file;

      Steps taken:

      u-pr-065% nexec -e DHCPIP=


      u-pr-065% nexec -e echo $DHCPIP


      u-pr-065% nexec -e export DHCPIP


      u-pr-065% nexec -e perl -ni -e 'print unless /($ENV{DHCPIP})/' hosts


      u-pr-065% cat hosts