#2784: [Execute] Escape call parameters for Windows
---------------------+--------------------
Reporter: Cas | Owner:
Type: bug | Status: new
Priority: minor | Milestone: 1.3.13
Component: Plugin | Version: 1.3.12
Resolution: | Keywords:
---------------------+--------------------
Comment (by Cas):
So the answer here is to escape the ampersand with a tripe-caret e.g.
`^^^&` and then quote any echo output in the batch script. This requires
more testing and a better understanding of how `getProcessOutputAndValue`
works so leaving this one for now.
{{{
from twisted.internet.utils import getProcessOutputAndValue
from twisted.internet import defer
from twisted.internet import reactor
import os
import traceback
@defer.inlineCallbacks
def runProgram():
torrent_id = "torrhash"
torrent_name = "test&name".replace('&', '^^^&')
download_location = "C:/dir"
command = "C:/Documents and Settings/Administrator/Desktop/test.bat"
args = (torrent_id, torrent_name, download_location)
try:
result = yield getProcessOutputAndValue(command, args,
env=os.environ)
print result
reactor.stop()
except Exception:
traceback.print_exc()
reactor.stop()
reactor.callLater(0, runProgram)
reactor.run()
}}}
{{{
import subprocess
torrent_id = 'torrhash'
torrent_name = 'test^^^&name'
download_location = 'C:/dir'
command = 'C:/Documents and Settings/Administrator/Desktop/test.bat'
result = subprocess.call([command, torrent_id, torrent_name,
download_location])
}}}
test.bat
{{{
@echo off
set torrentid=%1
set torrentname=%2
set torrentpath=%3
@echo "Torrent Details: %torrentname% %torrentpath% %torrentid%" >>
"%userprofile%\Desktop\execute_script.log"
}}}
--
Ticket URL: <http://dev.deluge-torrent.org/ticket/2784#comment:1>
Deluge <http://deluge-torrent.org/>
Deluge Project
--
You received this message because you are subscribed to the Google Groups
"Deluge Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/deluge-dev.
For more options, visit https://groups.google.com/d/optout.