Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
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 ?)
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
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: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
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.
Posts: 3,965
Threads: 176
Joined: Apr 2022
Reputation:
219
@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: 98
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,696
Threads: 327
Joined: Apr 2022
Reputation:
217
$Console:Only doesn't work in Linux? What flavor and version of Linux are you running?