Source language: Translate to:

Reading From Command Line Errors

General questions about NeoBook

Moderator: Neosoft Support

Reading From Command Line Errors

Postby krackerjaxz » Fri Aug 19, 2016 5:43 pm

While I'm familiar with NeoBook being able to use the Windows Command Line as well as being able to run local applications via the command line, I'm curious as to whether a NeoBook application can also obtain information from the command line. For example, if I ran the DOS command of "del c:\jkaslfkjslafjs.xyz" then the command line would normally return the error of "Could Not Find c:\jkaslfkjslafjs.xyz" In such a case, is there a way for a NeoBook app to retrieve any error thrown by the command line or the dos-based application?
krackerjaxz
 
Posts: 42
Joined: Sun Nov 24, 2013 8:58 am

Re: Reading From Command Line Errors

Postby Gaev » Fri Aug 19, 2016 6:21 pm

krackerjaxz:

Say you want to run a command like dir notexist.txt ... code your NeoBook command like so ...
Code: Select all
Run "dir" "notexist.txt 2> err.txt" "Normal" "ReadErrorFile" ""

... note that ...

a) 2> err.txt will direct STDERR messages to the file named err.txt ... for further info see https://support.microsoft.com/en-ca/kb/110930

b) ReadErrorFile is the name of a subroutine that will be serviced when your Run command is completed ... you can use this to read the contents of the error file ... like so ...
Code: Select all
:ReadErrorFile
FileRead "err.txt" "All" "[ErrorFileContent]"
AlertBox "Error File Content" "[ErrorFileContent]"
Return
... this is just a "proof of concept" ... you might want to first check for presence of any errors ... and perhaps not need the AlertBox as I have used.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Reading From Command Line Errors

Postby krackerjaxz » Fri Aug 19, 2016 8:08 pm

Awesome! Thanks for the info. I'm going to try to see if I can get it to assign the error message to a string (i.e. variable) and then have the Simple Text content to be the information that the variable contains (i.e. error message).
krackerjaxz
 
Posts: 42
Joined: Sun Nov 24, 2013 8:58 am


Return to General NeoBook Discussions

Who is online

Users browsing this forum: Bing [Bot] and 1 guest