Posts: 719
Threads: 113
Joined: Apr 2022
Reputation:
28
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/
Posts: 2,953
Threads: 348
Joined: Apr 2022
Reputation:
284
Usually the easiest way is to juust pipe the results into a text file and then read it back into your program.
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
^And then something similar to the above will read that file and print the results to the screen.
Posts: 719
Threads: 113
Joined: Apr 2022
Reputation:
28
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/
Posts: 4,104
Threads: 191
Joined: Apr 2022
Reputation:
264
@GearBear do offer Linux advice! I don't use Linux (yet) but I am sure this is helpful to those that do.
Besides mnr seems to have gone in hibernation.
b = b + ...
Posts: 80
Threads: 1
Joined: Jun 2023
Reputation:
3
Thanks!, bplus.
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.
Posts: 2,953
Threads: 348
Joined: Apr 2022
Reputation:
284
$Console:Only doesn't work in Linux? What flavor and version of Linux are you running?