lua-users home
lua-l archive

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

It was thus said that the Great Rob Kendrick once stated:
> On Wed, Sep 08, 2010 at 12:54:55AM +0300, soly man wrote:
> > when I  try to use this with lua i tried the following
> > 
> > osexecute(""C:\Program Files\WinSCP\WinSCP.exe" /console
> > /script="C:/puttyfac/ExtraPuTTY/Bin/winscp/winscpftp.txt"
> > /log="C:/puttyfac/ExtraPuTTY/Bin/winscp/winscplog.log"
> > ")
> > but i got an error
> Do we get to guess what the error was? :)  Anyway, you can't nest quotes
> like that.  Fortunately, Lua offers three ways of delimiting strings; ",
> ' and [[/]].  So simply change the outer quotes to one of the other two
> styles.
> B.

  Two things---one, a Lua string delimeted by the single or double quote use
the '\' as an escape character, so what Windows is seeing is not the string
you are giving it; you'll need to double up on the '\' character.

  Two:  Since the filenames in the string contain no spaces, the double
quotes around them are not necessary and can be removed.  So the following
examples should all work (each example on one line, in case it wraps):

os.execute('"C:\\Program Files\\WinSCP\\WinSCP.exe" /console /script="C:/puttyfac/ExtraPuTTY/Bin/winscp/winscpftp.txt" /log="C:/puttyfac/ExtraPuTTY/Bin/winscp/winscplog.log"')

os.execute("\"C:\\Program Files\\WinSCP\\WinSCP.exe\" /console /script=C:/puttyfac/ExtraPuTTY/Bin/winscp/winscpftp.txt /log=C:/puttyfac/ExtraPuTTY/Bin/winscp/winscplog.log")

os.execute('"C:\\Program Files\\WinSCP\\WinSCP.exe" /console /script=C:/puttyfac/ExtraPuTTY/Bin/winscp/winscpftp.txt /log=C:/puttyfac/ExtraPuTTY/Bin/winscp/winscplog.log')

os.execute [[ "C:\Program Files\WinSCP\WinSCP.exe" /console /script="C:/puttyfac/ExtraPuTTY/Bin/winscp/winscpftp.txt" /log="C:/puttyfac/ExtraPuTTY/Bin/winscp/winscplog.log" ]]

os.execute [[ "C:\Program Files\WinSCP\WinSCP.exe" /console /script=C:/puttyfac/ExtraPuTTY/Bin/winscp/winscpftp.txt /log=C:/puttyfac/ExtraPuTTY/Bin/winscp/winscplog.log ]]