comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic, 561.796.8997, M/S 731-96" <condicma@PWFL.COM>
Subject: Re: Command issuing
Date: 1997/10/16
Date: 1997-10-16T00:00:00+00:00	[thread overview]
Message-ID: <97101611481403@psavax.pwfl.com> (raw)


 "Robert A. Thompson" <stdrat01@UNX1.SHSU.EDU> writes:
>I have recently posted to news groups asking for help on Command line
>arguments.  I have recieved lots of help and information that I am
>extremely appreciative of, however I think I may have miss worded that.
>I need to know how to issue commands to the os not get the paramters
>issued when calling the program.  I would like to know how to issue a
>DIR... cd... or what ever to make an ada program emulate a batch file or
>something.  It does not have to be complex could some one show me how to
>write an ada program that could in esses make the program issue commands
>in a fashion I prefer.  ie. dir = ls  chmod = cacls etc... It would not
>have to be that complex.  If I could just see how to get the ada program
>to issue the command then I could get it to do everything else.  I would
>greatly appreciate it.
>
    It should be obvious, but often isn't, that anything which will
    cause O.S. CLI commands to be executed is going to be *extremely*
    dependent on the operating system, and hence is *way* beyond the
    scope of any language to define. Some operating systems don't have
    anything that resembles a CLI so there are no "dir" commands or
    anything similar.

    However, be that as it may, I've attached a procedure which will
    take a string containing a Unix command and execute it. (Others in
    this news group were kind enough to pass this on to me.) Note that
    this is only known to work for Unix and the compiler you are using
    needs to have implemented Interfaces.C. If you are working on a
    VMS machine or a WindowsNT machine or almost anything else, this
    procedure won't work without changes - and I have no way of
    knowing what those changes would be without knowing the OS in
    question.

    If this doesn't get your problem fixed, try posting again
    indicating a) the compiler you are using (including version
    number) and b) the operating system/hardware you are running on.
    The more complete the information the more likely you are to get
    some useful help.

    It sounds like you might be trying to build a more friendly shell
    for Unix - a noble ambition. Do you have a plan to make it look
    like some other shell? Or are you designing it from the ground up?

    MDC



with Interfaces.C;

procedure UTIL.Perform_System_Command (
    Command     : in     String ;
    Wait        : in     Boolean := True ;
    Success     :    out Boolean) is
    --
    Return_Code : Integer ;
    --
    function Sys (
        Item    : in     Interfaces.C.Char_Array) return Integer ;
    pragma Import (C, Sys, "system") ;
    --
    package C renames Interfaces.C ;
    --
begin
    --
    if (Wait) then
        Return_Code := Sys (
            Item    => C.To_C ("ksh -c " & '"' & Command & '"'));
    else
        Return_Code := Sys (
            Item    => C.To_C ("ksh -c " & '"' & Command & " &" & '"'));
    end if ;
    --
    if (Return_Code /= 0) then
        Success := False ;
    else
        Success := True ;
    end if;
    --
end UTIL.Perform_System_Command ;



Marin David Condic, Senior Computer Engineer     Voice:     561.796.8997
Pratt & Whitney GESP, M/S 731-96, P.O.B. 109600  Fax:       561.796.4669
West Palm Beach, FL, 33410-9600                  Internet:  CONDICMA@PWFL.COM
===============================================================================
    "Eagles may soar, but a weasle never gets sucked up into a jet engine."
===============================================================================




             reply	other threads:[~1997-10-16  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-16  0:00 Marin David Condic, 561.796.8997, M/S 731-96 [this message]
  -- strict thread matches above, loose matches on Subject: below --
1997-10-15  0:00 Command issuing Robert A. Thompson
replies disabled

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