01-31-2024, 01:31 AM (This post was last modified: 01-31-2024, 01:32 AM by PhilOfPerth.)
How does one access the C Prompt (CLI) from within a QBPE programme? I don't see any functions like CMD or COMMAND, but I know it can be (and is) done frequently by members. I've tried to interpret what they did, with no success. How do I get to put Shell "c: dir" (and others) into my programme? (maybe another lesson about CLI access etc ?)
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.)
Please visit my Website at: http://oldendayskids.blogspot.com/
01-31-2024, 10:50 AM (This post was last modified: 01-31-2024, 10:54 AM by PhilOfPerth.)
Thanks, all. But I'm afraid I wasn't able to get what I needed from any of those replies. (yes, Terry, I read all of those tuts).
There are obviously huge holes in my knowledge in this area. This code: Shell "c:\dir > temp.txt" ' <-- this runs that shell command to C:\DIR and then pipes the output to "temp.txt". Open "temp.txt" For Input As #1 Do Until EOF(1) Line Input #1, text$ Print text$ Loop
returns a blank window.
shell "CMD"
gives the c: prompt, which I can then use by entering that window and using DOS commands (e.g. dir c: ) to get the tree structure. I'd like to do all of that from within my programme. I suspect it's something to do with batch files, but I don't know how to run these from PE.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.)
Please visit my Website at: http://oldendayskids.blogspot.com/
Give the above a try. The issue with the blank screen was you specifying "c: dir" and me just plugging it in by mistake. There's no "dir.com", "dir.exe", or "dir.bat" file in the "c:\" directory, so no file to run and thus nothing to pipe.
By *just* using the DIR command, the system looks in the various paths and finds where that command is located, and then gives you a directory listing of C:\, as specified above.
Anytime you have issues with SHELL, test your command with $CONSOLE:ONLY. Then your QB64 program will run in the console/terminal and you'll see the output before that shell window opens and closes instantly on you. It's a great way to get those error messages and determine what the heck has gone wrong.
01-31-2024, 04:08 PM (This post was last modified: 01-31-2024, 04:09 PM by GareBear.)
To run this in linux console do this:
Code: (Select All)
$Console
Shell "ls > temp.txt" ' <-- this runs that shell command to ls to get a listing of the current directory, and then pipes the output to "temp.txt".
Open "temp.txt" For Input As #1
Do Until EOF(1)
Line Input #1, text$
Print text$
Loop
This will work for linux console. SMcNeill, I hope you don't mind the changes I made here.- GareBear
I wasn't sure if I could get it to work. When I remove the " :Only " from the $console command it works. It helps having both DOS and some linux commands for reference.