Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


return codes of a shell command


Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 06-14-2008, 06:33 AM
pmu5757's Avatar
Knows the basics
 
Join Date: Sep 2007
Location: Metz (France)
Posts: 53
Default

Agraham,
As I'm not a B4PPC expert, I think I need an example of using your library with its "lastexitcode" property.
Could you do it for me ?
I just need to launch a shell command and put its return code in a variable.
Thank you.

Pascal.
__________________
Pascal
Reply With Quote
  #12 (permalink)  
Old 06-14-2008, 12:03 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,759
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

I misquoted the name of the property, it is actually called ExitCode not LastExitcode. See example.
Attached Files
File Type: zip ProcessDemo.zip (4.4 KB, 8 views)
Reply With Quote
  #13 (permalink)  
Old 06-14-2008, 05:20 PM
pmu5757's Avatar
Knows the basics
 
Join Date: Sep 2007
Location: Metz (France)
Posts: 53
Default return codes of a shell command

Hello Agraham
Thank you for your example, it's very clear for a newbie like me.
But unfortunately, it doesn't work.

In a dos windows I type :
C:\>c:\nqc.exe -Susb -raw 120901
It answers :
54 00
This works

In your example, I use the line :
Process.Start("c:\nqc.exe" ,"-Susb -raw 120901")
Result : the command is launched (I can see the red light on the infrared lego tower), but a 0 is returned.

I suppose that your example only gets error codes and that "54 00" is not an error code. So it answers "0" that means "no error".

I then tried to redirect the result of the command in a text file :
In a dos widow, I type : C:\>c:\nqc.exe -Susb -raw 120901 > sortie.txt
Then the file "sortie.txt" contains "54 00" : it works.

In your code I then use the line : Process.Start("c:\nqc.exe" ,"-Susb -raw 120901 > sortie.txt")
I obtain the number "-13" that indicates an error I presume, because the file "sortie.txt" is neither created, nor modified if it exists...

I think I still need help...

Pascal.
__________________
Pascal
Reply With Quote
  #14 (permalink)  
Old 06-14-2008, 06:27 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,759
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by pmu5757
How can I do to set a B4PPC variable with the return code of this dos command ?
My example does just this. The problem is that it is not the return code that you require

Quote:
In a dos widow, I type : C:\>c:\nqc.exe -Susb -raw 120901 > sortie.txt
Then the file "sortie.txt" contains "54 00" : it works.
It looks like that app writes the number to StdOut. StdOut and redirection of it only exists for a console app running in a DOS window. Executing it directly under Windows using Shell doesn't provide access to StdOut. The following code line starts the command interpreter "cmd" and instructs it "/c" to execute the rest of the argument string then terminate.

Code:
Process.Start("cmd", "/c c:\nqc.exe -Susb -raw 120901 > " & AppPath & "\sortie.txt")
Reply With Quote
  #15 (permalink)  
Old 06-14-2008, 09:06 PM
taximania's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 237
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Reminds me of the old days when I wrote a mouse driver in assembly for a 286 that couldn't run windows.

ax
dx

etc ha ha ha
__________________
Endemol
Waste of space

O2 XDA Artemis Touch Flo 4.02 Full Cube Rom WM6.1

http://www.taximania.net
Reply With Quote
  #16 (permalink)  
Old 06-15-2008, 03:36 PM
pmu5757's Avatar
Knows the basics
 
Join Date: Sep 2007
Location: Metz (France)
Posts: 53
Default

Thank you Agraham.
your "cmd" works well with a line like :
Process.Start("cmd", "/c c:\nqc.exe -Susb -raw 120901 >> c:\sortie.txt")

But not with your line with the AppPath statement...

It doesn't matter, it's enough for me.

Best regards

Pascal.
__________________
Pascal
Reply With Quote
  #17 (permalink)  
Old 06-15-2008, 03:50 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,759
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by pmu5757 View Post
But not with your line with the AppPath statement
It should work - it does for me. Did you make a typo in appending the strings?

Note that you could revert to using the standard B4ppc "Shell" function as you don't need the return value.
Reply With Quote
  #18 (permalink)  
Old 06-15-2008, 05:39 PM
pmu5757's Avatar
Knows the basics
 
Join Date: Sep 2007
Location: Metz (France)
Posts: 53
Default

Sorry, but with my poor english, I don't understand what you mean with "make a typo in appending the strings".

Anyway, your other idea is good : using the "cmd" only when I need to return a value, and using the standard shell command if not.

Pascal.
__________________
Pascal
Reply With Quote
  #19 (permalink)  
Old 06-15-2008, 08:33 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,759
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by pmu5757 View Post
"make a typo in appending the strings".
Make a mistake when adding the three strings for the arguments parameter
"/c c:\nqc.exe -Susb -raw 120901 > " & AppPath & "\sortie.txt"

Quote:
using the "cmd" only when I need to return a value, and using the standard shell command if not.
What I meant was that you can use cmd with the standard Shell command instead of using Process as you don't want the exitcode of the app, only what it writes to StdOut.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Codes Unable to run no VISTA tcgoh Questions & Help Needed 4 08-19-2008 04:17 PM
Shell command J12345T Questions & Help Needed 2 06-08-2008 10:49 AM
Questions on shell command, and user event, and the 6.30 dan kabestan Questions & Help Needed 2 05-15-2008 07:45 PM
How to find out that Shell command has finished petrbury Questions & Help Needed 6 10-16-2007 08:20 PM
what are the codes for CR and LF? Stellaferox Questions & Help Needed 7 06-02-2007 08:15 PM


All times are GMT. The time now is 04:18 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0