From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b7c793204bb28111 X-Google-Attributes: gid103376,public From: "Marin David Condic, 561.796.8997, M/S 731-96" Subject: Re: Command issuing Date: 1997/10/16 Message-ID: <97101611481403@psavax.pwfl.com>#1/1 X-Deja-AN: 281018002 Sender: Ada programming language Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU X-VMS-To: SMTP%"INFO-ADA@VM1.NODAK.EDU" X-VMS-Cc: CONDIC Newsgroups: comp.lang.ada Date: 1997-10-16T00:00:00+00:00 List-Id: "Robert A. Thompson" 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." ===============================================================================