[wellylug] cgi script question
jumbophut
jumbophut at gmail.com
Sun Sep 12 22:12:38 NZST 2004
On Sat, 11 Sep 2004 12:55:03 +1200, Mark Signal wrote:
> Where the problem seems to occur is when the command is run
> from a directory that somewhere in its path there is a space as in "path/My
> Documents/rest of path" in which case it does squat. Interestingly if run
> from somewhere higher up the directory tree it correctly outputs all
> directories including those with spaces in their names.
>
> I don't know how to pipe a "find -exec" command through sed so I tried:
>
> for FILE in 'find `echo $DATADIR$HTTP_REFERER | cut -c 1-24,46-` -type f |
> sed 's/ /\\ /g'`';
> do
> ls $FIND | awk 'sub("$", "<br>")'
> done
>
If the webserver is sending back a path with a space in it, there is a
good chance it will encode it as '%20'. If that's the case, you need
to convert it to '\ ' (backslash plus space). Even if not, you will
probably find it helps to quote the string.
Something like this may do the trick:
myvar=$(echo $HTTP_REFERER | sed -e 's/%20/\\ /g')
find "$(echo $DATADIR$myvar | cut -c 1-24,46-)" -type -f -exec ls {} ';'
Hope that helps.
(By the way, if you use $() rather than ``, you can nest expressions,
which makes for more bash fun :-)
--
Tony (echo 'spend!,pocket awide' | sed 'y/acdeikospntw!, /l at omcgtjuba.phi/')
More information about the wellylug
mailing list