Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Execute Various Lines in same cmd sesion

Hello everyone,

I want to use the Execute comand of QV in order to copy a file from one path to another but I have 2 problems:

1- My path contains spaces

2- My file has dinamical name such as Name(Date).

3- I have to set a proxy to acces to the DB.

I tryed to create a . bat file but since my path contains spaces and i have to create the file dinamicaly Is not possible. The reason is that QV is adding extra " on the path and then the console does not recognize it as a path. I have read Extra double quotes when store as TXT | Qlik Community but using a .xml file i have then to convert it to .bat in order to use us it bu I can't do that becaus the path contains spaces.

I think that the simplest way to do this is with various lines in the same comand sesion:

EXECUTE cmd.exe /C set  ProxyVar=ProxyPath

ExacutableFile.bat

Is it possible? There is a way to save the .bat file without the extra "?

Thank you

1 Solution

Accepted Solutions
12 Replies
marcus_sommer

You could try this: Re: Writing .bat file through script

- Marcus

olivierrobin
Specialist III
Specialist III

hello

you can concatenate your commands with && so they execute in sequence only if the previous one succeeded

Anonymous
Not applicable
Author

Thank you both for your responses, both worked for the problem.


As for the && which is what I wanted in order to ease the script I see 2 limitations:

   

    1- You can not use the a QV variable inside the execute so you have to whrite the absolut path (which is a problem)


    2- All commands must be in the same line in order in order to be interpreted.


The 1 limitation is something that is kind of a limitation for the marcus_sommer‌ solution because in order to execute the bat file I need to hardcode the path of the file.

olivierrobin
Specialist III
Specialist III

for the 1st point, when you construct your commanf, you can use the $() syntax

say :

let vPath='c:\temp';

execute 'cmd /c del' & $(vPath)&'\*.qvd';

marcus_sommer

Three thoughts:

one - no outsourcing into an external bat-file else everything is executed directly from the qvw-script

two - switching the kind of batch-file to vbs might be useful to apply multiple actions

three - various parameters could be stored within text-files and read again from the batch-file to adress your dynamic requirements

It's not quite the same but it might be nevertheless helpful: Re: Stop Task from Command Line (cmd.exe)

- Marcus

Anonymous
Not applicable
Author

Did you test this?

The simple ' are a problem for QV.  Even the script: EXECUTE 'cmd.exe /c pause'; Gives me a "General Error" in response.

Also I have an other problem with the &&. When I use a script like:

Execute cmd.exe pause && copy FromPath ToPath && pause

Works but when I set a variable (in my case a proxy) does not give me an error but it is also not coping the file.

Execute cmd.exe set HTTPS_PROXY=SomPath && copy FromPath ToPath

olivierrobin
Specialist III
Specialist III

put the command into double quotes

try

execute "cmd.exe set HTTPS_PROXY=$(SomPath) && copy FromPath ToPath  "

assuming SomPath is a Qlik variable

Anonymous
Not applicable
Author

I tryed an it's not woerking, even if I use: execute "cmd.exe pause && copy FromPath ToPath" and is giving me "general error"

olivierrobin
Specialist III
Specialist III

try this syntax

execute cmd /c "your commands ..."

ex:

execute cmd /c  "pause && pause";