Author Topic: Using SHELL for external program  (Read 2411 times)

0 Members and 1 Guest are viewing this topic.

Offline vince

  • Newbie
  • Posts: 6
    • View Profile
Using SHELL for external program
« on: September 09, 2018, 04:20:23 pm »
Hi all

I am trying to run a program using the SHELL command, but the command is not running. Problem is I cant event determine what the issue is because the message that comes up in the DOS box after executing the SHELL command, disappears so quickly.

Is there any way I can stop the SHELL cmd window disappearing so I can read the error, if there is one. Or if anyone has any other idea how I can see this result of the SHELL, that would allow me to determine the problem.

Thanks

FellippeHeitor

  • Guest
Re: Using SHELL for external program
« Reply #1 on: September 09, 2018, 04:34:39 pm »
Try redirecting the output to a file:

SHELL "MYCOMMAND.EXE > DEBUG.TXT"

Welcome to the forum.

Marked as best answer by vince on September 10, 2018, 04:03:13 am

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Using SHELL for external program
« Reply #2 on: September 09, 2018, 06:05:50 pm »
or if the program output is short, use the BAT file:

OPEN "runme.bat" FOR OUTPUT AS #1
PRINT #1, "dir"
PRINT #1, "pause"
CLOSE


SHELL "runme"

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Using SHELL for external program
« Reply #3 on: September 10, 2018, 12:49:18 am »
Sometimes SHELL can't read a path, because a space is involved, like "c:\program files\" the way around that is to enclose it in quotes:

SHELL "c:\" + chr$(34) + "program files" + chr$(34) + "\myfile.exe"

Where chr$(34) represents the ASCII value for quote marks.

You can check out the _CONSOLE statement to keep the SHELL command window open in the WIKI.

You could try START as in SHELL _dontwait "START notepad.exe" START is usually implied in QB64 but it might be worth a try. Some Windows programs START will find, without including a path. Notepad is one of those types of programs. the .exe can be left off, as it is also implied.

Hope you get it working,

Pete

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline vince

  • Newbie
  • Posts: 6
    • View Profile
Re: Using SHELL for external program
« Reply #4 on: September 10, 2018, 07:07:03 am »
Hi all

Thanks for your responses. I tried all suggestions, but the batch file worked a treat. The command I ran in the SHELL command, it turns out, was not being recognised as an internal or external command. probably no surprise there, but I just couldn't be certain.

Thanks for all your input though.

Vince