Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
fkeuroglian
Partner - Master
Partner - Master

Command Execute in script

Hi expert i have a question

I create a qvw that in the script the only thing that have to do is run a bat

Execute cmd.exe /C C:\ProyectoQV\Homologacion\Bat\Copy.bat 

this bat is who copy some files to one location to other, if i run it manually the bat or if i run in qlikview works ok, but when i put in the qmc(console) and run, finish succesfull but do not copy, what could be?

thank you a lot

Fernando K.

14 Replies
petter
Partner - Champion III
Partner - Champion III

Your problems seem to stem from the lack of necessary rights to either files and or folders for the Service Account that the QlikView Server or QlikView Publisher is running under. Which you seem to have been discussing with Enrique already. However I have some more advice on effectively resolving these issues in general...

To pinpoint the problem it is very useful to catch the messages and error messages of the command line(s) of the bat-file in a log-file. Then you can retrospectively inspect these log-files and find out what went wrong. Furthermore it could be useful to have a log of these messages as a part of your production reload environment too since one day a batch file might fail and then you will have a log file to look into to find out what went wrong.

A command line program in Windows can write output that you usually get on the screen to two different output streams. They are called standard output and standard error. They can be activated so no messages go to the screen in this way:

(the two first lines will give a date time information before it starts the copy on the third line)

copy    abc.txt    def.txt    1>copy-log.txt    2>copy-errlog.txt

Then you can have a look at these two files to see wether the copy command worked as intended.

The following example will append to the files instead of overwriting them by using the double redirection  >>  :

echo %date% %time% copy attempted >>copy-log.txt

echo %date% %time% copy attempted >>copy-errlog.txt

copy    abc.txt    def.txt    1>>copy-log.txt    2>>copy-errlog.txt

You can even write both output streams to one file single log-file by doing this:

echo %date% %time% copy attempted >copy-log.txt

copy    abc.txt    def.txt    >>copy-log.txt    2>&1

You will have to append these "redirection" instructions to each of the command lines that you have in your bat-file. The single redirection will always overwrite and already existing file so the append redirection is very useful if you need to let multiple commands log messages in to the same log file.

These things are a bit cryptic but it is extremely useful for debugging purposes. You can find more information about it by Googling these words:

                    windows command line redirect stdout stderr

The first search entry results leading to Microsoft sites will give you a better understanding on how to use it.

fkeuroglian
Partner - Master
Partner - Master
Author

Hi Petter, thank you for your good explanation!

only two  question

1) The output of the error will be apeear in the screen, only in case it has an error? or save the copy-log.txt in some other folder?

2) if I do manually its run ok, but not from the console, instead of the user i have is the same in the console and localy doing manually, i have to see other permission apart from that?

thank you petter

fkeuroglian
Partner - Master
Partner - Master
Author

Petter, i find the copy-log text works!

let prove in the server i have the problem and notice you!

thank you a lot

petter
Partner - Champion III
Partner - Champion III

1) Yes you are right. But if the program does not produce its regular output to standard output - the status messages and error messages could be put into one single log file without problem.

2) Yes I think so

fkeuroglian
Partner - Master
Partner - Master
Author

Hi Enrique and Petter, i can solve the problem, but i do not why , I only change one thing:

Instead of reload and call a .bat to copy, i reload and execute the bat in the same script, and that works ok!

i dont know why, but works!

thank you both for your help

Fernando