LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Sys Exec to run an exe AND make it process a file.

Apologies for being thick! I would be very grateful if someone could assist me with this.
 
I have a DOS program called sendwrap.exe that (a) I want to run & (b) I also want to pass it a parameter that is a filename for it to process
 
I can get this to work using the following sequence of manual actions, what I need to know is how this sequence below translates to what i should wire to command line & standard input terminals of the sys exec vi
 
  1. Open Dos Window
  2. Type "CD C:\temp" :to change directory that containing sendwrap.exe program & eric.bin file to be processed
  3. Type "sendwrap eric.bin" :to invooke sendwrap.exe to process "eric.bin" file.

Thanks in advance for your help..

 
 
 
 
 
0 Kudos
Message 1 of 9
(4,327 Views)
I think it's better to write a small batch file, like:

MYJOB.BAT
c:
cd \temp
sendwrap %1

then execute the batch with eric.bin parameter on the command line:

MYJOB eric.bin


Paolo

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 9
(4,316 Views)
I think it's better to write a small batch file, like:

MYJOB.BAT
c:
cd \temp
sendwrap %1

then execute the batch with eric.bin parameter on the command line:

MYJOB eric.bin


Sorry I accidentally duplicated my post

Paolo

Message Edited by pincpanter on 05-15-2006 12:24 PM

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 9
(4,315 Views)

I have tried this, creating the batch file "myjob.bat" as you specify and then wiring  "myjob eric.bin" to the command line input but i receive an error 2

I also tried this with the working directory input of the vi as "C:\temp" and again with the directory my vi is in but to no avail..

0 Kudos
Message 4 of 9
(4,311 Views)
Probably the batch is not found. Try including the full path:

c:\mypath\myjob eric.bin

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 9
(4,308 Views)

I have tried the following:

"C:\temp\myjob eric.bin"  - This still returns error 2

"C:\temp\myjob.bat eric.bin - This displays an empty dos box with a cursor at the top but no prompt

Any ideas?

Thankyou

0 Kudos
Message 6 of 9
(4,305 Views)
It works for me with notepad as application.
Have you tested the bat "by hand", i.e. opening a dos box (not in c:\temp) and typing c:\temp\myjob.bat eric.bin ?
Does it work this way?

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 7 of 9
(4,297 Views)
Thanks paolo i have tweaked what i am doing and now it works perfectly!!
 
This has given rise to another question I would be most grateful if someone could answer.
 
When my .exe runs some text appears in the dos window showing progress of a file download in %. This text is updated on a single line as the download progresses.
 
1) Is there any way in which you can use sys exec.vi to repeatedly read the text output as it chnages?What i am trying to do is parse the text % value shown in the DOS box and use it to display progress on a Labview indictor progress bar.
 
Any tips to reading and parsing the DOS box text output would be very useful.
 
Thanks
 
Tristan
0 Kudos
Message 8 of 9
(4,290 Views)
There are a lot of threads on this forums treating this subject. You can find them, for example, searching "standard output". One is http://forums.ni.com/ni/board/message?board.id=170&message.id=57263&query.id=36730#M57263
The short answer is you can't do it.
What you can try to do is:

a) redirect the DOS program output this way:    sendwrap eric.bin > out.txt
b) periodically read this out.txt
c) from the file content, extract the last full line (in your case, lines are probably separated by a simple CR and not CR+LF)

a) and b) are not guaranteed to work; my main doubt is about reading out.txt during its update.
c) also requires some care, in case you read incomplete "lines"

An alternative approach would be to estimate the total time from the file size and outputting a time-based progress bar.

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 9 of 9
(4,283 Views)