08-25-2023, 01:55 PM
Having trouble Windows command line SORT via SHELL
|
08-25-2023, 02:07 PM
(This post was last modified: 08-25-2023, 10:46 PM by grymmjack.
Edit Reason: backtickify
)
(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. Add a SLEEPto see the command before the shell exits maybe too, so you can see it. Also in a real pinch CTRL+Swill stop flow control and pause if you catch it in time, and CTRL+Qwill resume. (I think that's the right order, I might have those flip-flopped). Also @TerryRitchie has good advice about trying from batch file. If you still see the window shutting on you before you can read it in batch file you call your QB program from, use a pausethere at the very end (same effect as QB64's SLEEP- will make you press a key - and even politely ask you to do so). What you're asking for for redirection should be possible in QB64 - it's called stdio(where i = input, o = output) there is also a stderrwhich is an error stream for info/warning/failures. By default windows supports that. You see it above with your >>redirection in your Sort_Command$. That means to append the output of command SORT x.xto the file y.y-- if you want to get a fresh copy each time use 1 >instead, which will reset/erase the file vs. append it. Hope this helps!
08-25-2023, 02:53 PM
Like I say, try it with quotes around the file names.
Code: (Select All)
It honestly sounds to me as if you're trying to use a file which the command line is seperating apart into multiple components such as "My Input File.txt". <-- With the spaces in that file, the command line will parse it as "My", "Input", "File.txt", which is three components rather than one. Enclose your file name in quotes and see how things work for you. ****************************** Step 2: Make certain that if on newer versions of Windows, you're going to a CMD window and not a Terminal as they're not always the same in how they handle things.
08-25-2023, 04:00 PM
(08-25-2023, 02:53 PM)SMcNeill Wrote: Like I say, try it with quotes around the file names.Good thinking @SMcNeill Try filename without spaces to eliminate the need for quotes possibly too.
08-25-2023, 10:26 PM
(08-25-2023, 01:17 PM)SpriggsySpriggs Wrote: 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. (08-25-2023, 01:55 PM)TerryRitchie Wrote:(08-25-2023, 01:17 PM)SpriggsySpriggs Wrote: 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.The >> means to redirect and append at the same time. Either redirect operator results in the same error outcome.
08-25-2023, 10:30 PM
(08-25-2023, 02:53 PM)SMcNeill Wrote: [snip] By going to a CMD window rather than a Terminal, are you referring to this? "QB64 automatically uses CMD /C when using SHELL, but it is allowed in a command string. Note: CMD alone may lock up program. Some commands may not work without adding CMD /C to the start of the command line." I tried adding CMD /C to no avail.
08-25-2023, 10:48 PM
@GTC could you share your program? Or at least a reproducible part that we can get the failure to happen with?
08-25-2023, 11:05 PM
(08-25-2023, 10:48 PM)grymmjack Wrote: @GTC could you share your program? Or at least a reproducible part that we can get the failure to happen with?Yes, I agree. We're just going to keep going in circles without something to debug.
Worked around. Instead of dealing with directory name strings in the SHELL command, I execute a BAT file and CD to the working directory ahead of the SORTs.
Now ... if you've been a programmer in a commercial environment for a reasonable length of time, you'll be aware of the adage "The user doesn't know what he wants until he sees what he gets". In my case the user now wants some post-sort processing so I'll use a bubble or quick sort internally. Thanks for all of the tips, guys. |
« Next Oldest | Next Newest »
|
Users browsing this thread: 5 Guest(s)