LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

question about system exce.vi

You should also read the this. Simply saying it doesn't work and you get an error is not sufficient. You don't speficy what command you are sending and you don't specify what the error number is. Please don't make the people here try to guess what you are doing. As I already said, I don't get an error with a proper command.

Edit:

Sorry I guess you were posting with the command at the same time I was posting my response. In order to do the cd command, I have to put the cmd /c in front.

Message Edited by Dennis Knutson on 07-20-2007 11:57 AM

0 Kudos
Message 11 of 21
(1,694 Views)
I have a simple question: Nevermind what you're doing. What are you fundamentally trying to accomplish? Perhaps you're going about it in a way that's more complicated than it needs to be?
0 Kudos
Message 12 of 21
(1,688 Views)
Got it, thanks.
0 Kudos
Message 13 of 21
(1,682 Views)
Hi, smercurio,
You are right, what I am trying to do is use another language "TCL" in Labview, becaue TCL is a MS-DOS program, so I want to creat a command prompt input in Labview. A detail discussion can be found in my previous post
 http://forums.ni.com/ni/board/message?board.id=170&message.id=256710&query.id=180382#M256710, this way (create a command prompt in labview) is an alternative way for calling the DLL in labview.
 
Mike

Message Edited by happybird on 07-20-2007 01:12 PM

Message Edited by happybird on 07-20-2007 01:13 PM

0 Kudos
Message 14 of 21
(1,682 Views)

Hi Dennis,

I have a MS-dos program shell  "Tclsh" in the folder C:\Tcl\bin, usually, when I run Tclsh in command prompt, I will be able to input Tcl (a langauage) command, like "puts {hellw, world} . but when I input the command in the labview as following: "cmd /c cd Tcl cd bin Tclsh" , it seems I did not get the correct output, because I still can not use Tcl command, could you please let me know a clue about that? thanks.

 

Mike

0 Kudos
Message 15 of 21
(1,644 Views)

A few pointers that may help,,,

The "command line" to system exec.vi runs a program, so for things like "dir" (which are commands to the command line interpreter) you need to tell it that the program to use is the command line interpreter, (cmd), and its command is "dir" so the line would be "cmd  /c  dir"

According to the help for cmd, the way of entering multiple cmd instructions in a single line is to separate them by &&, so in a command line you would type "cd Tcl\bin && Tcl"

Therefore, you would enter "cmd  /c  cd Tcl\bin && Tclsh" in your command line input to system exec.vi (Note that the space between cmd and /c is essential)

Alternatively, and for an easier solution, have you checked out the full help for command exec.vi? One of the inputs to the Vi (at least in 8.2) is "working directory". So you could put "C:\Tcl\bin" as the input to working directory, and "Tclsh" to command line and it should be OK. Also think if you want to have the vi wait until Tclsh finishes, or if you want it to continue while Tclsh runs. If your Tclsh uses the dos window for its input/output, and you want to be able to interact with it, you will want to set "wait until completion" to false.

BTW, using "help" rather than "cmd /c help" as input to the vi works because there is a program help.exe (which is also the program that is run when you type help at the command line interpreter)

Rod.

 

Message Edited by Rod on 07-30-2007 04:07 PM

0 Kudos
Message 16 of 21
(1,611 Views)

Hi Rod,

I have tried the first method, i input "cmd /c cd Tcl\bin & Tclsh" and I get a output "%" which is the same as in command prompt, then when I begin to input a TCL command after "cmd /c cd Tcl\bin & Tclsh"  like  " & puts {hello world}", I still can not get the "hello world" in the standard output.

Mike

 

"A few pointers that may help,,,

The "command line" to system exec.vi runs a program, so for things like "dir" (which are commands to the command line interpreter) you need to tell it that the program to use is

the command line interpreter, (cmd), and its command is "dir" so the line would be "cmd  /c  dir"

According to the help for cmd, the way of entering multiple cmd instructions in a single line is to separate them by &&, so in a command line you would type "cd Tcl\bin && Tcl"

Therefore, you would enter "cmd  /c  cd Tcl\bin && Tclsh" in your command line input to system exec.vi (Note that the space between cmd and /c is essential)

Alternatively, and for an easier solution, have you checked out the full help for command exec.vi? One of the inputs to the Vi (at least in 8.2) is "working directory". So you could put "C:\Tcl\bin" as the input to working directory, and "Tclsh" to command line and it should be OK. Also think if you want to have the vi wait until Tclsh finishes, or if you want it to continue while Tclsh runs. If your Tclsh uses the dos window for its input/output, and you want to be able to interact with it, you will want to set "wait until completion" to false.

BTW, using "help" rather than "cmd /c help" as input to the vi works because there is a program help.exe (which is also the program that is run when you type help at the command line interpreter)

Rod."

 

Message Edited by Rod on 07-30-2007 04:07 PM

0 Kudos
Message 17 of 21
(1,594 Views)

What you've just done is to give cmd the three commands

cd Tcl\bin

Tclsh

puts (hello world)

 

It won't understand the third one, and give you an error message when it tries to execute it [The error message will go to standard error] More importantly if there's nothing in standard input, when Tclsh runs it will have no commands.  Depending on how Tclsh works, it will either keep waiting for input from standard input (which never arrives) or it sees an end of file on stdin and terminate.

The second method in my previous message is probably better, but in any case the puts.. is standard input and not the command!

Remember you should probably put the wait for completion? to false if you want to interact at the keyboard with Tclsh. If you just want to give Tclsh a series of commands from your vi without keyboard interaction, enter them into the vi's standard input, (probably separated by new lines, but check how Tclsh works) and see the result in standard output.

 

Rod.

 

 

0 Kudos
Message 18 of 21
(1,588 Views)
I would like to explain the function of "Tclsh", it is a TCL langauage shell, so in MS-DOS command prompt, it functions as follows, % is just a symbol at the beginning of each Tcl command line, "puts" is a TCL command.
 
C: \Tcl\bin\Tclsh
% puts {hello world}
hello world
%
...
...
 
Mike
 
 
0 Kudos
Message 19 of 21
(1,584 Views)

Hi Rod,

It seems to me that this will not work, as I am trying to input a TCL command in labview, that will require the standard I/O of TCL, but system exec.VI can only accept a MS-Dos command, so when I input "Tclsh" in the command line, I can get "%" symbol as in command prompt, but I can not continue to input a TCL command after the "% "symbol, is my understanding correct?

 

Mike

0 Kudos
Message 20 of 21
(1,573 Views)