caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Ocaml equivalent of python's
@ 2002-02-06 14:03 Johann Spies
  2002-02-06 18:07 ` Xavier Leroy
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Johann Spies @ 2002-02-06 14:03 UTC (permalink / raw)
  To: caml-list

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 = <fun>
# 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


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

end of thread, other threads:[~2002-02-08 20:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-06 14:03 [Caml-list] Ocaml equivalent of python's Johann Spies
2002-02-06 18:07 ` Xavier Leroy
2002-02-07  6:30   ` Johann Spies
2002-02-06 18:15 ` Remi VANICAT
2002-02-07  9:14 ` Nicolas barnier
2002-02-08  2:20   ` Julian Assange
2002-02-08 20:29   ` Chris Hecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).