From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA08936; Wed, 6 Feb 2002 18:47:57 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA09532 for caml-list@pauillac.inria.fr; Wed, 6 Feb 2002 18:47:56 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA04010 for ; Wed, 6 Feb 2002 15:03:44 +0100 (MET) Received: from maties2.sun.ac.za (maties2.sun.ac.za [146.232.128.10]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g16E3fn03958 for ; Wed, 6 Feb 2002 15:03:42 +0100 (MET) Received: from bywoner.sun.ac.za ([146.232.129.121]) by maties2.sun.ac.za with esmtp (Exim 3.34 #1) id 16YSfi-0003d5-00 for caml-list@inria.fr; Wed, 06 Feb 2002 16:03:38 +0200 Received: from js by bywoner.sun.ac.za with local (Exim 3.33 #1 (Debian)) id 16YSff-0007F3-00 for ; Wed, 06 Feb 2002 16:03:35 +0200 Date: Wed, 6 Feb 2002 16:03:35 +0200 From: Johann Spies To: caml-list@inria.fr Subject: [Caml-list] Ocaml equivalent of python's Message-ID: <20020206140335.GA27734@adept.co.za> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.25i X-Scanner: exiscan *16YSfi-0003d5-00*OVum663GfO2* http://duncanthrax.net/exiscan/ Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I want to learn how to use Unix commands from within an Ocaml program but the Ocaml manual confused me more than it helped me to understand the Ocaml way. In Python I can do the following; ------------------------------ import commands, os listing = os.system ('ls -laprt') #or any other unix command print listing # to get the output of the unix command. address = 146.232.128.13 result = commands.getstatusoutput('ping -c 1 %s' % address,) print result ----------------------------------- What would the equivalent be in Ocaml? I have tried ------------------------------------------------- # let listing = Unix.execv "ls -laprt";; val listing : string array -> unit = # let l = Array.to_list listing;; This expression has type string array -> unit but is here used with type 'a array ------------------------------------------------- Johann -- Johann Spies Telefoon: 021-808 4036 Informasietegnologie, Universiteit van Stellenbosch "He hath not dealt with us after our sins; nor rewarded us according to our iniquities. For as the heaven is high above the earth, so great is his mercy toward them that fear him. As far as the east is from the west, so far hath he removed our transgressions from us." Psalms 103:10-12 ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr