Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / send and return results from darkbasic to command prompt

Author
Message
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 25th Jul 2009 07:20
I was wondering if there was a way to send a command to the command prompt. Then posibbly send the result to a text file or just straight back to DarkBASIC.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 25th Jul 2009 07:22
I think you can send it to the command prompt using the EXECUTE FILE command. Saw it done once, just don't remember exactly which argument was used off the top of my head

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 25th Jul 2009 15:08
Quote: "I think you can send it to the command prompt using the EXECUTE FILE command. Saw it done once, just don't remember exactly which argument was used off the top of my head"


I don't think thats possible. or are you getting Command Prompt and Command Line confused?


you could write to a batch file from dbc then run that and in the batch file have it write to a text file and read it in from dbc.

i'm not sure if you can do read and write operations in the Command Prompt though. i bet it's possible.

New Site! Check it out \/
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 25th Jul 2009 22:26
Yeah, now that I tracked down the old thread, it was executing an exe that was USED by the command prompt (if I recall how it all worked correctly). It was for printing, but it was only for serial/com ports, no usb.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 25th Jul 2009 23:46
You can run CMD.EXE and tell it to write a file with the > sign.

This following will tell it to write the directory listing into a file called test.txt in the root directory. The /c tells Windows to automatically close the command prompt window after it's done doing the command.



Using /k instead of /c will keep the command prompt window open.



And Caleb1994 is right about the .bat files. You want to use a .bat file if you want to do multiple commands with one EXECUTE FILE command.



To get it back to Darkbasic though you'd have to open the text file and read the strings.

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 27th Jul 2009 05:26
Quote: "execute file "cmd.exe","/c test.bat","C:\"
"


Why would you execute command prompt to execute a batch file? just execute the batch file directly.


New Site! Check it out \/
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 27th Jul 2009 07:41
My only defense is I forgot to test that method before posting.

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th Jul 2009 08:11
My guess is that he's talking about the CLI anyway...

TDK

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 27th Jul 2009 21:02 Edited at: 27th Jul 2009 22:38
Quote: "My only defense is I forgot to test that method before posting. "


ha


Quote: "My guess is that he's talking about the CLI anyway...
"


well he did say this:

Quote: "or just straight back to DarkBASIC. "


if he was talking about the CLI then it wouldnt need to go "Back" to darkbasic it would still be in it.

New Site! Check it out \/
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 29th Jul 2009 21:47
What I was trying to do was get information from the cmd.exe like the current user and ip, then send it directly back to DB or to a txt file that db can then read.

I ended up figuring it out thanks to grog and created a function that will return the IP$ address of the current user.

Here's the function:



Here's how you would use it:

Login to post a reply

Server time is: 2024-05-20 05:33:11
Your offset time is: 2024-05-20 05:33:11