This shows you the differences between two versions of the page.
Last revision Both sides next revision | |||
returning_20errors_20from_20windows_20commands [2018/03/31 14:19] 127.0.0.1 external edit |
returning_20errors_20from_20windows_20commands [2018/04/14 18:22] richardrussell Added syntax highlighting |
||
---|---|---|---|
Line 1: | Line 1: | ||
=====Returning errors from Windows commands===== | =====Returning errors from Windows commands===== | ||
- | //by Jonathan Harston, August 2010//\\ \\ The OSCLI command can be used to execute a Windows command. However, if the command fails, no error is generated, the Windows command interpreter merely // | + | //by Jonathan Harston, August 2010//\\ \\ The OSCLI command can be used to execute a Windows command. However, if the command fails, no error is generated, the Windows command interpreter merely // |
+ | |||
+ | <code bb4w> | ||
DEF FNwin_cmd(cli$) | DEF FNwin_cmd(cli$) | ||
LOCAL ch%, | LOCAL ch%, | ||
Line 8: | Line 10: | ||
err$=GET$# | err$=GET$# | ||
=err$ | =err$ | ||
- | \\ | + | </ |
+ | |||
+ | This redirects the error output to a file, then reads that file to see if anything has been output to it. Bear in mind that if the called command displays its error reports to // | ||
===== Examples ===== | ===== Examples ===== | ||
+ | < | ||
>PRINT FNwin_cmd(" | >PRINT FNwin_cmd(" | ||
' | ' | ||
Line 15: | Line 21: | ||
> | > | ||
- | \\ | + | </ |
+ | |||
+ | Note that, as opposed to OSCLI itself, the command is //always// passed to Windows. In the second example above, the Windows **DIR** command is executed, which will result in a directory listing appearing in a DOS command box before quickly | ||
===== References ===== | ===== References ===== | ||
* http:// | * http:// |