comp.lang.ada
 help / color / mirror / Atom feed
* Using Spawn in Win2K
@ 2002-05-06 20:44 Dave Head
  2002-05-06 21:05 ` Dave Head
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Dave Head @ 2002-05-06 20:44 UTC (permalink / raw)


Hello,

I have been trying to use spawn just to get it to give me a directory.
Someday, if I ever get a directory, I might like to pipe it to a file.  But,
first things first.

I've been wasting an incredible amount of time tripping thru about 10 years
of google newsgroup posts viewing people asking about spawn with as many
years of creative ways of not anwering the question.  What I'm looking for
is a specific example.  Here's what I have so far:

with GNAT.OS_Lib;

procedure test_OSLib is

Success : BOOLEAN;
Cmd : String := "Dir";
Cmd_ptr : GNAT.OS_Lib.String_Access;
Cmd_array : GNAT.OS_Lib.Argument_List(1..1);

begin

    Cmd_ptr := new String'(Cmd);
    Cmd_array(1) := Cmd_ptr;
    GNAT.OS_Lib.Spawn
        ("Command.Com",
          Cmd_array,
          Success);

end test_OSLib;

...And this is the response:


Specified COMMAND search directory bad
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-1999.

Howcum?  Because, as far as a search of the C: drive can tell, there is no
"command.com" on the disk. Again, this is W2K.

So, please, what goes where I have "command.com"?  Or, can it be done at all
in W2K?  Later, when that is working, and I want to say "dir >filename.txt"
to throw the output into a file, can the entire phrase "dir >XXX.XXX" be
thrown into the string, or do each of "dir", ">" and "XXX" have to be a
different string for the Cmd_array to point to?

Thanks in advance,

Dave Head





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Using Spawn in Win2K
  2002-05-06 20:44 Using Spawn in Win2K Dave Head
@ 2002-05-06 21:05 ` Dave Head
  2002-05-06 23:42   ` Jeffrey Carter
  2002-05-06 21:49 ` Stephen Leake
  2002-05-07 17:06 ` Björn Lundin
  2 siblings, 1 reply; 12+ messages in thread
From: Dave Head @ 2002-05-06 21:05 UTC (permalink / raw)


Further info...  I _found_ command.com under c:\winnt\system32.  Why wasn't
it found in the search starting at c:\?  I dunno - prolly misspelt it.  But,
I put the whole path into the spawn for the command. Same result.  So, not
only don't I know how to get it working, I've got nary a clue as to why it
doesn't.

Please help.

Dave Head


"Dave Head" <headdp@nswc.navy.mil> wrote in message
news:ab6q0l$4g6$1@oanews.nswc.navy.mil...
> Hello,
>
> I have been trying to use spawn just to get it to give me a directory.
> Someday, if I ever get a directory, I might like to pipe it to a file.
But,
> first things first.
>
> I've been wasting an incredible amount of time tripping thru about 10
years
> of google newsgroup posts viewing people asking about spawn with as many
> years of creative ways of not anwering the question.  What I'm looking for
> is a specific example.  Here's what I have so far:
>
> with GNAT.OS_Lib;
>
> procedure test_OSLib is
>
> Success : BOOLEAN;
> Cmd : String := "Dir";
> Cmd_ptr : GNAT.OS_Lib.String_Access;
> Cmd_array : GNAT.OS_Lib.Argument_List(1..1);
>
> begin
>
>     Cmd_ptr := new String'(Cmd);
>     Cmd_array(1) := Cmd_ptr;
>     GNAT.OS_Lib.Spawn
>         ("Command.Com",
>           Cmd_array,
>           Success);
>
> end test_OSLib;
>
> ...And this is the response:
>
>
> Specified COMMAND search directory bad
> Microsoft(R) Windows DOS
> (C)Copyright Microsoft Corp 1990-1999.
>
> Howcum?  Because, as far as a search of the C: drive can tell, there is no
> "command.com" on the disk. Again, this is W2K.
>
> So, please, what goes where I have "command.com"?  Or, can it be done at
all
> in W2K?  Later, when that is working, and I want to say "dir
>filename.txt"
> to throw the output into a file, can the entire phrase "dir >XXX.XXX" be
> thrown into the string, or do each of "dir", ">" and "XXX" have to be a
> different string for the Cmd_array to point to?
>
> Thanks in advance,
>
> Dave Head
>
>





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Using Spawn in Win2K
  2002-05-06 20:44 Using Spawn in Win2K Dave Head
  2002-05-06 21:05 ` Dave Head
@ 2002-05-06 21:49 ` Stephen Leake
  2002-05-07 17:06 ` Björn Lundin
  2 siblings, 0 replies; 12+ messages in thread
From: Stephen Leake @ 2002-05-06 21:49 UTC (permalink / raw)


"Dave Head" <headdp@nswc.navy.mil> writes:

> <snip>
> So, please, what goes where I have "command.com"?  

command.com is a 16 bit application. Use cmd.exe instead.

> Or, can it be done at all in W2K? 

I've never done this, but it should work :). 

> Later, when that is working, and I want to say "dir >filename.txt"
> to throw the output into a file, can the entire phrase "dir
> >XXX.XXX" be thrown into the string, 

Probably. Give it a try.

> >or do each of "dir", ">" and "XXX" have to be a different string
> for the Cmd_array to point to?

If the first one doesn't work, try this :).

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Using Spawn in Win2K
  2002-05-06 21:05 ` Dave Head
@ 2002-05-06 23:42   ` Jeffrey Carter
  2002-05-07  0:41     ` DPH
  0 siblings, 1 reply; 12+ messages in thread
From: Jeffrey Carter @ 2002-05-06 23:42 UTC (permalink / raw)


Dave Head wrote:
> 
> Further info...  I _found_ command.com under c:\winnt\system32.  Why wasn't
> it found in the search starting at c:\?  I dunno - prolly misspelt it.  But,
> I put the whole path into the spawn for the command. Same result.  So, not
> only don't I know how to get it working, I've got nary a clue as to why it
> doesn't.

I can't vouch for Win2k. Under Win98, I have a program that does

   procedure Create_File_List is
   -- Use DOS dir command to create list of signature-file names
      Arg     : Os_Lib.Argument_List_Access;
      Success : Boolean;
   begin -- Create_File_List
      Arg := Os_Lib.Argument_String_To_List ("/c dir/-p/b signature?? >
" &                                              File_List_Name);
      
      Ensure_Success : loop
         Os_Lib.Spawn (Program_Name => "command", Args => Arg.all,
                       Success => Success);
         
         exit Ensure_Success when Success;
      end loop Ensure_Success;
   end Create_File_List;

-- 
Jeff Carter
"You empty-headed animal-food-trough wiper."
Monty Python & the Holy Grail



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Using Spawn in Win2K
  2002-05-06 23:42   ` Jeffrey Carter
@ 2002-05-07  0:41     ` DPH
  2002-05-07  1:47       ` David C. Hoos, Sr.
  0 siblings, 1 reply; 12+ messages in thread
From: DPH @ 2002-05-07  0:41 UTC (permalink / raw)


Wow!  Just what I needed.  Thanks a lot, Jeffry.

If you don't mind, 1 further question.  What is the "/c" right at the
beginning of the argument_string_list?  I found this on a search of
the web (as opposed to the search of the newsgroups) too.  I musta
missed something about calling command.com?

Dave Head


On Mon, 06 May 2002 23:42:49 GMT, Jeffrey Carter <jrcarter@acm.org>
wrote:

>Dave Head wrote:
>> 
>> Further info...  I _found_ command.com under c:\winnt\system32.  Why wasn't
>> it found in the search starting at c:\?  I dunno - prolly misspelt it.  But,
>> I put the whole path into the spawn for the command. Same result.  So, not
>> only don't I know how to get it working, I've got nary a clue as to why it
>> doesn't.
>
>I can't vouch for Win2k. Under Win98, I have a program that does
>
>   procedure Create_File_List is
>   -- Use DOS dir command to create list of signature-file names
>      Arg     : Os_Lib.Argument_List_Access;
>      Success : Boolean;
>   begin -- Create_File_List
>      Arg := Os_Lib.Argument_String_To_List ("/c dir/-p/b signature?? >
>" &                                              File_List_Name);
>      
>      Ensure_Success : loop
>         Os_Lib.Spawn (Program_Name => "command", Args => Arg.all,
>                       Success => Success);
>         
>         exit Ensure_Success when Success;
>      end loop Ensure_Success;
>   end Create_File_List;




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Using Spawn in Win2K
  2002-05-07  0:41     ` DPH
@ 2002-05-07  1:47       ` David C. Hoos, Sr.
  2002-05-07  8:23         ` DPH
  0 siblings, 1 reply; 12+ messages in thread
From: David C. Hoos, Sr. @ 2002-05-07  1:47 UTC (permalink / raw)



----- Original Message -----
From: "DPH" <rally2xs@compuserve.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: May 06, 2002 7:41 PM
Subject: Re: Using Spawn in Win2K


> Wow!  Just what I needed.  Thanks a lot, Jeffry.
>
> If you don't mind, 1 further question.  What is the "/c" right at the
> beginning of the argument_string_list?  I found this on a search of
> the web (as opposed to the search of the newsgroups) too.  I musta
> missed something about calling command.com?
>
As with all DOS and Windows commands issued at the command line,
the correct syntax is obtained by issuing the command with the
switch /?

So for the command shell, you obtain the following:

command /?
Starts a new instance of the MS-DOS command interpreter.

COMMAND [[drive:]path] [device] [/E:nnnnn] [/P] [/C string] [/MSG]

  [drive:]path    Specifies the directory containing COMMAND.COM file.
  device          Specifies the device to use for command input and output.
  /E:nnnnn        Sets the initial environment size to nnnnn bytes.
  /P              Makes the new command interpreter permanent (can't exit).
  /C string       Carries out the command specified by string, and then stops.
  /MSG            Specifies that all error messages be stored in memory. You
                  need to specify /P with this switch.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Using Spawn in Win2K
  2002-05-07  1:47       ` David C. Hoos, Sr.
@ 2002-05-07  8:23         ` DPH
  0 siblings, 0 replies; 12+ messages in thread
From: DPH @ 2002-05-07  8:23 UTC (permalink / raw)


On Mon, 6 May 2002 20:47:23 -0500, "David C. Hoos, Sr."
<david.c.hoos.sr@ada95.com> wrote:

>
>----- Original Message -----
>From: "DPH" <rally2xs@compuserve.com>
>Newsgroups: comp.lang.ada
>To: <comp.lang.ada@ada.eu.org>
>Sent: May 06, 2002 7:41 PM
>Subject: Re: Using Spawn in Win2K
>
>
>> Wow!  Just what I needed.  Thanks a lot, Jeffry.
>>
>> If you don't mind, 1 further question.  What is the "/c" right at the
>> beginning of the argument_string_list?  I found this on a search of
>> the web (as opposed to the search of the newsgroups) too.  I musta
>> missed something about calling command.com?
>>
>As with all DOS and Windows commands issued at the command line,
>the correct syntax is obtained by issuing the command with the
>switch /?
>
>So for the command shell, you obtain the following:
>
>command /?
>Starts a new instance of the MS-DOS command interpreter.
>
>COMMAND [[drive:]path] [device] [/E:nnnnn] [/P] [/C string] [/MSG]
>
>  [drive:]path    Specifies the directory containing COMMAND.COM file.
>  device          Specifies the device to use for command input and output.
>  /E:nnnnn        Sets the initial environment size to nnnnn bytes.
>  /P              Makes the new command interpreter permanent (can't exit).
>  /C string       Carries out the command specified by string, and then stops.
>  /MSG            Specifies that all error messages be stored in memory. You
>                  need to specify /P with this switch.

Well, I feel silly.  Thanks, David.  I forgot about that.  And I've
never had occasion to call command.com from a program before.  Duh.

Dave Head



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Using Spawn in Win2K
  2002-05-06 20:44 Using Spawn in Win2K Dave Head
  2002-05-06 21:05 ` Dave Head
  2002-05-06 21:49 ` Stephen Leake
@ 2002-05-07 17:06 ` Björn Lundin
  2002-05-07 17:36   ` Dave Head
  2 siblings, 1 reply; 12+ messages in thread
From: Björn Lundin @ 2002-05-07 17:06 UTC (permalink / raw)


Dave Head wrote:

> 
> Specified COMMAND search directory bad
> Microsoft(R) Windows DOS
> (C)Copyright Microsoft Corp 1990-1999.
> 
> Howcum?  Because, as far as a search of the C: drive can tell, there is no
> "command.com" on the disk. Again, this is W2K.

> Dave Head
The command interpreter in dos + Win9x is command.com.
However, the command interpreter in NT4 and W2000 is cmd.exe

/Bj�rn



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Using Spawn in Win2K
  2002-05-07 17:06 ` Björn Lundin
@ 2002-05-07 17:36   ` Dave Head
  2002-05-07 19:34     ` Randy Brukardt
  0 siblings, 1 reply; 12+ messages in thread
From: Dave Head @ 2002-05-07 17:36 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 865 bytes --]

Thanks.

I did find CMD.  But this is going to make it more fun to produce something
for people with the different OS's and have it work the same...  command.com
wants to give 8X3 filenames no matter what.  CMD does long filenames, no
problem, and by default too.

It must be quitting time somewhere in the world...

Dave Head


"Bj�rn Lundin" <bjorn.lundin@swipnet.se> wrote in message
news:6QTB8.4153$iB4.10546@nntpserver.swip.net...
> Dave Head wrote:
>
> >
> > Specified COMMAND search directory bad
> > Microsoft(R) Windows DOS
> > (C)Copyright Microsoft Corp 1990-1999.
> >
> > Howcum?  Because, as far as a search of the C: drive can tell, there is
no
> > "command.com" on the disk. Again, this is W2K.
>
> > Dave Head
> The command interpreter in dos + Win9x is command.com.
> However, the command interpreter in NT4 and W2000 is cmd.exe
>
> /Bj�rn





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Using Spawn in Win2K
  2002-05-07 17:36   ` Dave Head
@ 2002-05-07 19:34     ` Randy Brukardt
  2002-05-07 20:02       ` Dave Head
  0 siblings, 1 reply; 12+ messages in thread
From: Randy Brukardt @ 2002-05-07 19:34 UTC (permalink / raw)


Dave Head wrote in message ...
>Thanks.
>
>I did find CMD.  But this is going to make it more fun to produce
something
>for people with the different OS's and have it work the same...
command.com
>wants to give 8X3 filenames no matter what.  CMD does long filenames,
no
>problem, and by default too.
>
>It must be quitting time somewhere in the world...

Trying to use "spawn" to get a list of files seems like killing a flea
with a cannon. And, as you've found out, its not in the least portable
(even to different versions of windows). There are lots of good uses for
Spawn (or 'Prog_Call' as it is called in Janus/Ada, ...), but this isn't
one of them.

If you need to find a list of information about files in a directory,
you are best off using a package designed for the purpose. The first
choice would be Ada.Directories, but it probably will be a few years
before that is generally available. But there are a lot of other choices
available:

-- Claw.Directories: Windows-specific. Works on any Ada compiler for
Windows. (But it is tied into Claw, so if you're using a different GUI,
or no GUI, it may be a bad choice.)

-- Compiler-specific:
   Gnat.Directories: Gnat-specific. Works (supposedly) on any Gnat
supported OS. Every other Ada compiler has such a library as well.

You also could use Florist or other of the other OS-interface packages.

Any of these choices would be less platform-specific than using Spawn.

            Randy Brukardt.








^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Using Spawn in Win2K
  2002-05-07 19:34     ` Randy Brukardt
@ 2002-05-07 20:02       ` Dave Head
  2002-05-07 23:23         ` Randy Brukardt
  0 siblings, 1 reply; 12+ messages in thread
From: Dave Head @ 2002-05-07 20:02 UTC (permalink / raw)



"Randy Brukardt" <randy@rrsoftware.com> wrote in message
news:udgb1hnacmmh49@corp.supernews.com...
> Dave Head wrote in message ...
> >Thanks.
> >
> >I did find CMD.  But this is going to make it more fun to produce
> something
> >for people with the different OS's and have it work the same...
> command.com
> >wants to give 8X3 filenames no matter what.  CMD does long filenames,
> no
> >problem, and by default too.
> >
> >It must be quitting time somewhere in the world...
>
> Trying to use "spawn" to get a list of files seems like killing a flea
> with a cannon.

I've been known to do that... I buy cars with big engines, too... <G>

 And, as you've found out, its not in the least portable
> (even to different versions of windows). There are lots of good uses for
> Spawn (or 'Prog_Call' as it is called in Janus/Ada, ...), but this isn't
> one of them.

OK.


> If you need to find a list of information about files in a directory,
> you are best off using a package designed for the purpose. The first
> choice would be Ada.Directories, but it probably will be a few years
> before that is generally available. But there are a lot of other choices
> available:


> -- Claw.Directories: Windows-specific. Works on any Ada compiler for
> Windows. (But it is tied into Claw, so if you're using a different GUI,
> or no GUI, it may be a bad choice.)

Isn't that tied to $$$.  And, no gui - its too simple - a GUI would be
overkill.

> -- Compiler-specific:
>    Gnat.Directories: Gnat-specific. Works (supposedly) on any Gnat
> supported OS. Every other Ada compiler has such a library as well.

Found G-direop.ads .. adb.  OK, but it appears as if one needs to

1) Open the directory (how to open the current directory?  Research here -
I'm just getting started with this.  Prolly Get_Current_Dir.  Yeah - duh...)
2) Use procedure Read in a loop until it finds the end, while
3) Storing each file name into the dos file I wanted.
4) Close the file

That is slightly more complicated.  I'll probably do it for the portability.
Thanks for the info.  I guess I didn't read g-direop.ads closely enough to
notice you could do that.  Of course, I approached it _wanting_ to do "dir/b
>XXX.XXX" which seemed awful simple at the time. <G>

> You also could use Florist or other of the other OS-interface packages.

Web search in order - just getting started with gnat/dos/windows and haven't
heard of these yet.

> Any of these choices would be less platform-specific than using Spawn.

Oh, yeah...  I'll likely stick with the gnat stuff, tho

Thanks again,

Dave Head

>
>             Randy Brukardt.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Using Spawn in Win2K
  2002-05-07 20:02       ` Dave Head
@ 2002-05-07 23:23         ` Randy Brukardt
  0 siblings, 0 replies; 12+ messages in thread
From: Randy Brukardt @ 2002-05-07 23:23 UTC (permalink / raw)


Dave Head wrote in message ...
>
>> -- Claw.Directories: Windows-specific. Works on any Ada compiler for
>> Windows. (But it is tied into Claw, so if you're using a different
GUI,
>> or no GUI, it may be a bad choice.)
>
>Isn't that tied to $$$.  And, no gui - its too simple - a GUI would be
>overkill.

Claw.Directories is in the Claw Introductory Edition, which is now
licensed under the GMGPL. So no $ required for that. (If you need
support or to go beyond the Intro version, then you need to pay, of
course. Neither is necessary here.)

>> -- Compiler-specific:
>>    Gnat.Directories: Gnat-specific. Works (supposedly) on any Gnat
>> supported OS. Every other Ada compiler has such a library as well.
>

[SNIP, to meet the don't quote too much requirement]
>
>That is slightly more complicated.  I'll probably do it for the
portability.
>Thanks for the info.  I guess I didn't read g-direop.ads closely enough
to
>notice you could do that.  Of course, I approached it _wanting_ to do
"dir/b
>>XXX.XXX" which seemed awful simple at the time. <G>


Yup, seems simple at first. Then it gets pretty complicated (in any
language). While the package (any of them) seems complicated at first,
but it doesn't get any worse...

                 Randy.






^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2002-05-07 23:23 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-06 20:44 Using Spawn in Win2K Dave Head
2002-05-06 21:05 ` Dave Head
2002-05-06 23:42   ` Jeffrey Carter
2002-05-07  0:41     ` DPH
2002-05-07  1:47       ` David C. Hoos, Sr.
2002-05-07  8:23         ` DPH
2002-05-06 21:49 ` Stephen Leake
2002-05-07 17:06 ` Björn Lundin
2002-05-07 17:36   ` Dave Head
2002-05-07 19:34     ` Randy Brukardt
2002-05-07 20:02       ` Dave Head
2002-05-07 23:23         ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox