Jump to content
Sign in to follow this  
Travis

arguments to command line utility

Recommended Posts

Travis

Hi all,

I'm writing this program that involves selecting a file to then be sent to another command line utility. The format is like this:

msvsplit.exe -vag $file

Where $file would be like (with quotes) "c:\programs\input.imf"

For some weird reason, I am unable to use the complete path as returned by FileOpenDialog(). I have tried writing the exact same output I get directly into the function (That is, Run()) and it works fine!

Here is my code that produces problems:

#include <Constants.au3>
$openfile = FileOpenDialog("",@ScriptDir,"(*.imf)")
$fline = Chr(34) & $openfile & Chr(34)
ConsoleWrite($fline)        ; for debugging
$cmd = Run("msvsplit.exe -vag " & $fline,@ScriptDir,@SW_HIDE,$STDOUT_CHILD)
While 1
    $out = Stdoutread($cmd)
    If @error then Exitloop
    ConsoleWrite($out)
WEnd

$openfile would = "c:\programs\input.imf", yet it does not work when that variable is called with Run() as I said above. But if I change the Run() to

$cmd = Run("msvsplit.exe -vag " & '"c:\programs\input.imf"',@ScriptDir,@SW_HIDE,$STDOUT_CHILD)

It will work fine! Why does this keep happening? I have even gone to the extend of ensuring there were no invalid characters in the path, so ran StringStripWS but not dice. Any help will be appreciated :)

Share this post


Link to post
Share on other sites
enaiman

Maybe because msvsplit.exe expects to "see" the file name enclosed in quotes; if it is not then it may assumes that it's not a file name but other string of arguments.

Try this value: $fline = """ & $openfile & """


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.