Having trouble Windows command line SORT via SHELL - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10) +---- Thread: Having trouble Windows command line SORT via SHELL (/showthread.php?tid=1932) Pages:
1
2
|
Having trouble Windows command line SORT via SHELL - GTC - 08-24-2023 My program generates 12 output files that then need to be sorted, and I'd rather do those sorts from within the app (via SHELL) than have to use SORT standalone from the command line afterwards. Here's an example of how I'm calling it: Sort_Command$ = "SORT " + "x.x" + " >> " + "y.y" SHELL Sort_Command$ If I type that sort command on the command line I get y.y as a sorted version of x.x ... which is desired. However when executed via SHELL a message flashes up in the output window (too fast to read before a blank window replaces it), and no sort occurs. I have used SHELL previously with other commands and experienced no problems. Is there a way of directing the contents of the output window to a file, so that I can read whatever is being shown on that? RE: Having trouble Windows command line SORT via SHELL - TerryRitchie - 08-24-2023 (08-24-2023, 02:42 PM)GTC Wrote: My program generates 12 output files that then need to be sorted, and I'd rather do those sorts from within the app (via SHELL) than have to use SORT standalone from the command line afterwards.Just off the top of my head: - Make sure the SORT command is in the same folder as program's executable, the SORT command's location is included in your PATH, or you are supplying the path to the SORT command in your executable. - Try using "Start SORT ..." instead. - Create a batch file (.BAT) and try calling the batch file instead. - Make sure your spacing is correct within your build string. You might need a space preceding y.y ( " y.y" ) ( update: I see you did that with " >> " ) RE: Having trouble Windows command line SORT via SHELL - GTC - 08-24-2023 Thanks for the suggestions. SORT is part of Windows as an "external command" and is therefore "pathed" by Windows. The command line spacing is correct. It works fine when typed at the command line level. I'll try a BAT file. Just wish I could see what is being briefly flashed up on the output window. QB64 ought to allow users to redirect such messages to a file. IIRC VB has that option. RE: Having trouble Windows command line SORT via SHELL - Dimster - 08-24-2023 Are you sorting zero values or negative values? Is it possible the SHELL message is to the effect that it finds no ">>" in the very first sorting pair? RE: Having trouble Windows command line SORT via SHELL - SMcNeill - 08-24-2023 You probably need to delimitate your components better. For example: SHELL "Sort " + CHR$(34) + "C:/My Stuff/My File.txt" + CHR$(34) RE: Having trouble Windows command line SORT via SHELL - SMcNeill - 08-24-2023 For the quick flash issue, manually display the console yourself. $CONSOLE _CONSOLE ON RE: Having trouble Windows command line SORT via SHELL - Ed Davis - 08-24-2023 (08-24-2023, 02:42 PM)GTC Wrote: Here's an example of how I'm calling it: Bad news here: It works fine for me Code: (Select All) $console:only Something to try - probably won't make a difference, but change "sort " to "sort.exe ". Both work the same here. RE: Having trouble Windows command line SORT via SHELL - GTC - 08-25-2023 (08-24-2023, 04:53 PM)SMcNeill Wrote: For the quick flash issue, manually display the console yourself. Thanks for the tip. To keep the contents from disappearing I had to use: $CONSOLE _CONSOLE ON _DEST _CONSOLE RE: Having trouble Windows command line SORT via SHELL - GTC - 08-25-2023 (08-24-2023, 08:32 PM)Ed Davis Wrote: Bad news here: It works fine for me Thanks to the tip from @SMcNeill, now that I can hold the output screen and read the message, SORT is saying "Input file specified two times." ... which is not the case! At command line level, the only way to get that error message is to omit the redirect operator. However my command string includes the redirect operator so this is just nuts. RE: Having trouble Windows command line SORT via SHELL - SpriggsySpriggs - 08-25-2023 Should you be using two greater-than signs rather than one? I thought you only needed one for redirection. Maybe that's why it is saying you did it twice. |