Author Topic: Command line syntax like '"--csv-header > %file%' (with Redirection) dont't work  (Read 175 times)

weissenb

  • Newbie
  • *
  • Posts: 14
Hello!
I converted the speedtest Python-based command line programm "speedtest-cli.exe" (https://www.speedtest.net/de/apps/cli) to run with WinBatch and added CSV output (in DOS the syntax is e.g.: " --csv-header > %csvfile%" or  "--csv >> %csvfile%".

The command line itself runs very well but with the redirection leads to an error message.
This works: Run( "C:\Python\Scripts\speedtest-cli.exe", "")
But ths not: Run( "C:\Python\Scripts\speedtest-cli.exe", "--csv-header > %csvfile%")

Thank you very much for helping!

Best Regards, Christian Weissenberger

jmburton2001

  • Jr. Member
  • **
  • Posts: 78
The command line itself runs very well but with the redirection leads to an error message.
This works: Run( "C:\Python\Scripts\speedtest-cli.exe", "")
But ths not: Run( "C:\Python\Scripts\speedtest-cli.exe", "--csv-header > %csvfile%")

If it were me I'd concatenate the parameters instead of placing both hardcoded and variables together.

Example:

Code: Winbatch
; Instead of:
Run( "C:\Python\Scripts\speedtest-cli.exe", "--csv-header > %csvfile%")

; Do this:
CompleteParams = StrCat ("--csv-header > ", csvfile)
Run ( "C:\Python\Scripts\speedtest-cli.exe", CompleteParams)
 

It's been my experience that combining hardcoded and variables in the parameters field results in inconsistent (or failed) results.

YMMV  ;)

td

  • Tech Support
  • *****
  • Posts: 3455
    • WinBatch
Good advice but there is also a basic misunderstanding of the Windows command line in the OP's script.  The redirect operation ">>" syntax is implemented by the Windows command line "cmd.exe".  That command line syntax means nothing the exe or WinBatch.  The issue is explained here:

https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/DOS+Slash~C~and~Redirection~Symbol~Not~Working.txt
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

weissenb

  • Newbie
  • *
  • Posts: 14
Thanks a lot! This works!

Best Regards, Christian

N.B: If quotes are needed, this syntax works:
script_param_T = StrCat( '/c %python38_script_fdir% >"', csvfile_speedtest_fdir, '"' )
RunWait(Environment("COMSPEC"), script_param_T )