Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: OT: Shell script



If you want your script to treat blanks and "bad characters" as every
other character you also could do something like this:

Script1.sh:
=================================================
#!/bin/bash
OFS=${IFS}
# ! The next 2 lines *must* be left as are !
IFS='
'
SRC="foo bar yugga yugga"

# Variable $SRC has the complete string (including) "bad" characters
echo $SRC >out1.txt
script2 $SRC

# restore file separator
IFS=${OFS}
~ ...more script statements... ~



Script2.sh:
=================================================
#!/bin/sh

OFS=${IFS}
# ! The next 2 lines *must* be left as are !
IFS='
'
echo $1 > out2.txt

# restore file separator
IFS=${OFS}
~ ...more script statements... ~


@Thomas Keil:

Single quotes (') won't be a good idea, because in upper example you'd
actually pass the string "$SRC" to the second script and not, as
intended, the content of $SRC :)


Thomas Keil wrote:
> Martin Hoffmann schrieb:
> 
>> Hi,
>>
>> does anyone know how to call a shell script from another and give a 
>> filename as paramterer just _exactly_ as it is ? Without bash 
>> interpreting anything ?
>>
>> I have this problem, that certain filenames (from VDR) are changed 
>> when giving them as argument to a second script ! Especially ' 
>> characters, which are also ommited when using echo, are interpreted, 
>> or dropped it seems !
>>
>> Example:
>> #!/bin/sh
>> # Variable $SRC has the complete string (including) "bad" characters
>> echo $SRC >out1.txt
>> script2 $SRC
>>
>> #!/bin/sh
>> # this is script2 !
>> echo $1 > out2.txt
>>
>> out1.txt and out2.txt differ ! The second one has the characters 
>> stripped off already :-(
>>
>> Also script2 "$SRC" did not change anything :-(
>>
>> btw: echo $SRC (to the console) gives same output as out2.txt is ! But 
>> out1.txt is different !
>>
>> Anyone ?
>>
>> Martin
>>
>>
>>
>>  
>>
> Maybe you should have a look at
> http://www.tldp.org/LDP/abs/html/quoting.html
> probably the answer lies there.
> 
> I'm also trying to figure something out....
> 
> 
> 
> 


-- 
with best regards
--
Karsten Mueller
Softwaredevelopment / Keyaccount Manager
RATIO Entwicklungen GmbH
Admiralitaetstr. 59
20459 Hamburg
Email: mailto:kmu@ratio.de






Home | Main Index | Thread Index