Page 1 of 1

parameter with quote mark

Posted: 12 Dec 2017, 11:09
by dandan
Hi,

I try to start a program and I need to use a parameter containing quote mark (because there is a space in the path)
for example

program.exe -path-to-config="c:\project\project 1\project.prj"

Unfortunately, I saw that the quotes are not parsed when using them in the parameters field and therefore my program loads without the config.
Anyone knows how to force Actiona to parse the quotes when used in the parameters?

Thanks,
Dan

Re: parameter with quote mark

Posted: 13 Dec 2017, 18:05
by eureka
Sometimes I just call from Actiona command a python wrapper script which uses subprocess
to allow long commands, with multiple args, to be invoked.

Have you tried single quotes?

Re: parameter with quote mark

Posted: 14 Dec 2017, 08:27
by dandan
Yes, I have tried single quotes. It doesn't work... I also tried to escape using \, also no success

Re: parameter with quote mark

Posted: 14 Dec 2017, 10:52
by eureka
This is an example of what I have in mind.

Write python wrapper script .. command.py .. and save in same directory as your *.ascr script.

[command.py]

Code: Select all

#!/usr/bin/env python

import subprocess

def runcmd():
    p = subprocess.Popen(["program.exe", "-path-to-config='c:\project\project 1\project.prj' "], stdout=subprocess.PIPE)
    print p.communicate()[0]    

if __name__ == "__main__":
    runcmd()
Test that the python script works on its own.

Code: Select all

python command.py
Then inside Actiona you can simply write path to the python script ..

Code: Select all

Command: python
Parameters: command.py
Other than this idea does the Actiona command work if you use “project_1” instead of “project 1” .. i.e. drop spaces in path?

Re: parameter with quote mark

Posted: 14 Dec 2017, 13:58
by dandan
thanks eureka for answering.
some thoughts:
1. usually the parameter is in a variable - would the python wrapper work also in this case?
2. transforming a path to have it without space is not an option. And yes, when there are no spaces, the Actiona script works.
I have tested also with the fart.exe ( Find and Replace Text) program and it also doesn't work, for example when using:
program: fart.exe
parameters: -C text_to_replace "replacement text"

Re: parameter with quote mark

Posted: 14 Dec 2017, 15:51
by eureka
Windows is not my main OS (I have dual boot Ubuntu+Windows) so I'm a bit rusty on escaping paths in Windows.

Reading further, would this work ..

Code: Select all

program.exe -path-to-config="c:\project\'project 1'\project.prj"
or this ..

Code: Select all

program.exe -path-to-config="c:\project\projec~1\project.prj"

Re: parameter with quote mark

Posted: 14 Dec 2017, 16:25
by dandan
Hi eureka,

many thanks for the hint - it worked with projec~1. On the other hand, putting the path with space between the single quotes did not work.
However, since I will (later) also need to find and replace some text (using fart.exe) or any other similar utility, I would definitely need to use the double quotes, so I still need some solution for using them in the parameter field.
Anyway, at least I have managed to start the program with the help of your hint.