[Gambas-user] a Dumb shell question - passing quoted text

Doriano Blengino doriano.blengino at ...1909...
Thu Feb 11 12:49:35 CET 2010


Benoît Minisini ha scritto:
>> Hi List,
>>
>> I want to end up with this text to pass to the shell, and it contains
>> quotation marks, I wondered how to do that.
>>
>> wkhtmltopdf *.html /tmp/temp.pdf --toc --header-right "Page [page]"
>>  --footer- center "- EasyGP Medical Records -" --footer-spacing 5
>>  --footer-font-name "comic sans ms"
>>
>> any help appreciated.
>>
>> Regards
>>
>> Richard
>>
>>     
>
> In Gambas 3, you can use the Shell$() function to quote arguments sent to a 
> shell.
>
> And in your example, you should better use Exec instead of Shell to run the 
> command.
>
> Regards,
>
>   
Agreed for using EXEC instead of SHELL. (but he wants to expand *.html).

Anyway, you can use tickmarks (single quotes) instead of double quotes 
in your command line.
If the text enclosed by single quotes does not need to be expanded by 
the shell, then single quotes are good if not better. Don't put 
asterisks inside single quotes, unless you really mean "*" and not "all 
files".
Your command line could be:

    EXEC "wkhtmltopdf *.html /tmp/temp.pdf --toc --header-right 'Page 
[page]' ... ..."
    ' see "Page [page]" surrounded by ticks

Ciao,
Doriano





More information about the User mailing list