[ale] name=value

Wandered Inn esoteric at denali.atlnet.com
Fri Jul 16 08:41:27 EDT 1999


Zhongbin Yu \"jerry\" wrote:
> 
> I would do it with "cut"
> thingIwant=`echo $1|cut -d "=" -f 2`
> if $1 is name=123.
> And that's a pair of back ticks there.
> 
> Caution should be taken when parsing form inputs if the web server is on
> the internet. Better use CGI module along wiht taint. Oh, hm, that's perl.
> Alright, I'd prefer to use Perl for CGI purpose, personally. If you still
> want continue with shell CGI, real UNIX folks will teach you how to use
> AWK.

I would agree with using perl, but you can split the input out using awk
by defining the filed separator, for example the following code:

echo name=value | awk '{FS='='; print $2}'

yields:

value

Using bash or ksh, you can get at it as follows:

name=value

# comes in as $1, so..

echo ${1#*=}

# yields

value


> 
> just wanna help.
> 
> Jerry Yu
> ----------------------------------------------------------------------------
> Systems Engineer        | zyu at tc.net
> Premiere Technologies   | 404-262-8544(O)       1-800-979-1105 (P)
> Atlanta, GA 30326       | ae.tc.net/dept/engineering/op/public/developer/zyu
> 
> On Thu, 15 Jul 1999, Bert Hiddink wrote:
> 
> #Hello,
> #
> #I am new on this list and very new on shell scripting.
> #
> #I have this script:
> #
> ##!/bin/sh
> #echo Content-type:text/html
> #echo
> #
> #/usr/local/bin/analog32 +g/usr/home/coninpym/analog/analog.cfg +F-00-
> #00-$1 +T-00-00-01
> #
> #$1 is the variable I need to execute properly the analog32. I works
> #when I do this through a link from the web f.e.
> #
> #http://www.mysite.net/cgi-bin/analog.sh?123
> #
> #where 123 corresponds to the value of $1.
> #
> #However, now I want to control this through a form f.e.:
> #<INPUT CHECKBOX NAME=analog VALUE=123>
> #The problem is that then not only the value is send to the server but
> #also the 'name'. So the script receives 'analog=123' instead of
> #'123'.
> #
> #I suppose I should do a split once the variable arrives at the script
> #but I do not know  where to start. Could you help me?
> #
> #Thanks in advance and best regards,
> #
> #-brt
> #
> #
> #   Bert Hiddink, FUNDACION GALILEO
> #   Correo electronico: hiddink at sipromicro.com
> #   Sitio: http://www.sipromicro.com
> #   Tel. (506) 280 8683, telefax. (506) 280 8847
> #

--
Until later: Geoffrey		esoteric at denali.atlnet.com

It should be illegal to yell "Y2K" in a crowded economy.
	-- Larry Wall, creator of the programming language Perl






More information about the Ale mailing list