[Gambas-user] Shell command including string containing a quote

John Rose john.aaron.rose at ...626...
Tue Jan 29 17:02:29 CET 2013


Tobias,

Thanks for that useful reply.

I have a quick question (it doesn't seem worth asking on the Mailing List):
Using Dialog.OpenFile(), the resulting Dialog.Path shows the full path 
to the file (e.g. /home/john/x.txt). Given that the runtime user might 
change to a different directory (from that specified in Dialog.Path - 
/home/john/ - as a prior command to Dialog.OpenFile()) how can I obtain 
the new directory (e.g. /home/john/abc/) easily? I thought of using a 
string function to select characters before the final slash character 
but then the filename might contain a slash....

Regards,
John

On 24/01/13 21:08, Tobias Boege wrote:
> On Thu, 24 Jan 2013, John Rose wrote:
>> I have written a GUI to execute a command which involves selecting
>> filenames (e.g. sCombinedPath below) to be used in a Shell command
>> (as part of a Process). It works OK generally. However, if any
>> filename includes a quote, it goes wrong.
>>
>> sCommand = "mplex -f 8 -o " & "'" & sCombinedPath & "' " &
>>                                  "'" & sVideoPath & "' " &
>>                                  "'" & sAudioPath & "' " &
>>                                  ">/dev/null 2>'" & sLogFilename & "'"
>>    Print sCommand
>>    hProcess = Shell sCommand
>>
>> I read about using the Shell$ command to create a quoted string but
>> I couldn't make that work. I've also tried a Replace$ command to
>> replace a quote by a backslash followed by a quote. I couldn't get
>> that to work.
> Use it like
>
> sCommand = "mplex ... " & Shell$(sCombinedPath) & etc.
>
> This will result in
>
> mplex ... /path/with/\"quotes\"
>
> which is totally valid. But then you must not enclose the path within ''
> single quotes.
>
> Regards,
> Tobi
>
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user





More information about the User mailing list