Loading ...
Sorry, an error occurred while loading the content.

Sys.command does not do its job when the command contains a cd

Expand Messages
  • Marco
    Hello all, the following two lines of Ocaml code below say it all ... does anyone know how to fix this ? OCaml version 4.00.0 # Sys.command pwd ;;
    Message 1 of 4 , Dec 31, 2012
    • 0 Attachment
      Hello all,

      the following two lines of Ocaml code below say it all ... does anyone know how to fix this ?

      OCaml version 4.00.0

      # Sys.command "pwd";;
      /Users/ewandelanoy/Documents/OCaml/Ordinary
      - : int = 0
      # Sys.command "cd /usr";;
      - : int = 0
      # Sys.command "pwd";;
      /Users/ewandelanoy/Documents/OCaml/Ordinary
      - : int = 0


      Ewan
    • Philippe
      Hi Ewan, What you observe is expected, as Sys.command creates a new process to execute a command. So in your example you re changing the pwd of the child proce
      Message 2 of 4 , Dec 31, 2012
      • 0 Attachment
        Hi Ewan,

        What you observe is expected, as Sys.command creates a new process to
        execute a command. So in your example you're changing the pwd of the
        child proce



        Le 31 déc. 2012 à 15:08, "Marco" <roparzhhemon@...> a
        écrit :

        >
        >
        > Hello all,
        >
        > the following two lines of Ocaml code below say it all ... does
        > anyone know how to fix this ?
        >
        > OCaml version 4.00.0
        >
        > # Sys.command "pwd";;
        > /Users/ewandelanoy/Documents/OCaml/Ordinary
        > - : int = 0
        > # Sys.command "cd /usr";;
        > - : int = 0
        > # Sys.command "pwd";;
        > /Users/ewandelanoy/Documents/OCaml/Ordinary
        > - : int = 0
        >
        >
        > Ewan
        >
        >
        >
        >
        > ------------------------------------
        >
        > Archives up to December 31, 2011 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners
        > The archives of the very official ocaml list (the seniors' one) can
        > be found at http://caml.inria.fr
        > Attachments are banned and you're asked to be polite, avoid flames
        > etc.Yahoo! Groups Links
        >
        >
        >
      • Philippe
        Sorry, I hit the send button by mistake. In your example you change the pwd of the child process, which has no effect on your toplevel. Instead you want to
        Message 3 of 4 , Dec 31, 2012
        • 0 Attachment
          Sorry, I hit the 'send' button by mistake. In your example you change
          the pwd of the child process, which has no effect on your toplevel.
          Instead you want to use Sys.chdir to change the current working
          directory in your program.

          Hope it helps !

          Philippe.


          Le 31 déc. 2012 à 15:08, "Marco" <roparzhhemon@...> a
          écrit :

          >
          >
          > Hello all,
          >
          > the following two lines of Ocaml code below say it all ... does
          > anyone know how to fix this ?
          >
          > OCaml version 4.00.0
          >
          > # Sys.command "pwd";;
          > /Users/ewandelanoy/Documents/OCaml/Ordinary
          > - : int = 0
          > # Sys.command "cd /usr";;
          > - : int = 0
          > # Sys.command "pwd";;
          > /Users/ewandelanoy/Documents/OCaml/Ordinary
          > - : int = 0
          >
          >
          > Ewan
          >
          >
          >
          >
          > ------------------------------------
          >
          > Archives up to December 31, 2011 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners
          > The archives of the very official ocaml list (the seniors' one) can
          > be found at http://caml.inria.fr
          > Attachments are banned and you're asked to be polite, avoid flames
          > etc.Yahoo! Groups Links
          >
          >
          >
        • Marco
          ... It does help! Thanks a lot. Ewan
          Message 4 of 4 , Dec 31, 2012
          • 0 Attachment
            --- In ocaml_beginners@yahoogroups.com, Philippe <philippe.veber@...> wrote:
            > Hope it helps !
            >

            It does help! Thanks a lot.

            Ewan
          Your message has been successfully submitted and would be delivered to recipients shortly.