![]() |
|
Shell issues - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Shell issues (/showthread.php?tid=3662) |
Shell issues - eoredson - 05-05-2025 Hi, When using Shell with no parameters the program displays a blank screen which cannot be exited without going to Task Manager->Processes and manually right-click and end task!? Instead I am using Shell "Cmd" to properly starting a dos-like window shell and prompt to exit. Why is this? And does Linux/MacOsX require other than "Cmd" to load shell? Should I otherwise use the following: Code: (Select All) Comspec$=Environ$("COMSPEC")Thank you, Erik. This is some code I have been using: Code: (Select All) ' program to shell to windowRE: Shell issues - SMcNeill - 05-05-2025 (05-05-2025, 03:03 AM)eoredson Wrote: When using Shell with no parameters the program displays a blank screen which cannot be exited From reading the above, it sounds like you're writing a program such as this: Code: (Select All) SHELLAnd then you mention this: (05-05-2025, 03:03 AM)eoredson Wrote: Also, the Wiki says to use Shell "Cmd /C" or it may hang.. Looks to me like you wrote and answered yourself. What am I missing here? If you read the CMD help info, you see this: /C Carries out the command specified by string and then terminates... If you're just looking to open a command window, and not have it automatically terminate, just do: Code: (Select All) SHELL "CMD"That /C is for executing commands and closing after, so if you leave it blank, you execute nothing and then close. "CMD" alone should be all you need to open a command window and keep it open for whatever purpose. RE: Shell issues - eoredson - 05-07-2025 Although I may have answered my own post and it works!? It doesn't explain the following: 1)why does shell w/o parameter hang? 2)what is the equivalent to CMD in Linux and MacOsX? 3)does or should comspec$ be used? Thank you, Erik. RE: Shell issues - ahenry3068 - 05-07-2025 (05-07-2025, 12:26 AM)eoredson Wrote: Although I may have answered my own post and it works!? There isn't an exact one to one equivalent to CMD in Linux. Depending on what you want to actually accomplish you want to use either xdg-open or the executable name of your favorite xterm type program (xterm, gterm, konsole etc...) RE: Shell issues - SMcNeill - 05-07-2025 Shell by itself hangs because it waits for a exit code to continue and return back to your program. Of course, if you just shell to nothing, there's nothing to return an exit code, and thus it just enters an endless loop waiting for an exit code that will never come. See this little code snippet for an example: Code: (Select All)
Run that, it'll print 1 to 10 on the console. Then it'll wait for you to type something into the command line. Type "EXIT" so the shell ends. It'll then continue and print 11 to 20 on the console. Where it'll then wait for the "EXIT" to be typed to end your use of the command line. SHELL waits for whatever it shells to to end before it returns control back to QB64. So a blank SHELL with nothing inside it can't send a termination code, so it's just going to wait forever and ever and ever.... COMSPEC$ doesn't need to be used. Just SHELL "CMD" as I did above. It really is that simple. RE: Shell issues - eoredson - 05-07-2025 (05-07-2025, 04:34 AM)SMcNeill Wrote: Shell by itself hangs because it waits for a exit code to continue and return back to your program. Of course, if you just shell to nothing, there's nothing to return an exit code, and thus it just enters an endless loop waiting for an exit code that will never come.Ok, thanks. That's what I thought. RE: Shell issues - hsiangch_ong - 05-07-2025 since linux could be "many" operating systems to some people. there are many terminal emulators. some of them friendlier than others. sadly must go through a list of possible emulators. as was already said. it's not reliable on some systems using "xdg-open" or other gag. for example if an user wants to use "thunar" file manager. but didn't choose xfce desktop environment. this is possible in eg. cinnamon. since "nemo" is slow as a hog and has other performance issues. such as its failure to mark the current position when "page up" and "page down" keys are used. the "example" command to open a terminal for the current directory. works on "thunar" in xfce. but fails when "thunar" is used in a different desktop. on kde "konsole" is the only acceptable choice. start the search with that one. then go through others like "gnome-terminal". "xfce-terminal". "mate-terminal". "qterminal" this is the one for lxqt. might have to go through others which are lesser known. such as "rox-terminal" a good one which sadly needs to be compiled on some systems. a few users have this monster: https://man.archlinux.org/man/urxvt.7 note that on debian/ubuntu this is called "rxvt-unicode". this might be enough: Code: (Select All) xdg-open /path/to/the/folderCode: (Select All) mate-terminal --working-directory=/path/to/the/folderwill need to provide the folder. but usually this is the user's home. i wanted to answer the question here. but was trying to use "bash" command in various ways and failed. it must be through a terminal emulator. RE: Shell issues - eoredson - 05-10-2025 Sounds like alot of Shell functions when all I needed was: MS-DOS - Command.com Windows - Cmd.exe And Comspec usually returns one of the above.. Erik. |