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

Re: "ocaml_beginners"::[] file gets deleted on subsequent program executions

Expand Messages
  • Oliver Bandel
    Hello, ... What does roughly mean? Can you show the whole code? ... [...] This looks like problems must occur somehow ;-) Bette code the following way: let _
    Message 1 of 8 , Jul 1, 2008
      Hello,


      Zitat von Ashish Agarwal <agarwal1975@...>:

      > I'm having a strange problem. My program deletes files created by a
      > previous
      > invocation even though I'm changing the file name! My program is
      > roughly the
      > following:


      What does "roughly" mean?

      Can you show the whole code?



      > let open_out_safe = open_out_gen [Open_wronly; Open_creat; Open_excl;
      > Open_text] 0o666
      > (* this is similar to open_out but does not overwrite the file if it
      > exists
      > *)
      >




      > Then I do:
      >
      > let cout = open_out "a.txt"
      > ... do some calculations and print to cout ...
      > let _ = close_out cout
      [...]


      This looks like problems must occur somehow ;-)

      Bette code the following way:


      let _ =
      cout = open_out "a.txt" in
      (* do something *)
      close_out cout

      From your email text it seems that you have defined
      cout at the compilation-unit's toplevel.
      And that you also do the calculations and printings
      on the toplevel of the compilation unit.

      Better do it like I wrote above.


      Ciao,
      Oliver
    • Richard Jones
      ... OCaml doesn t do anything very different from C programs. I suggest that you strace your program to see what actual system call it is making (ie. to
      Message 2 of 8 , Jul 1, 2008
        On Mon, Jun 30, 2008 at 07:24:10PM -0400, Ashish Agarwal wrote:
        > I'm having a strange problem. My program deletes files created by a previous
        > invocation even though I'm changing the file name! My program is roughly the
        > following:
        > let open_out_safe = open_out_gen [Open_wronly; Open_creat; Open_excl;
        > Open_text] 0o666

        OCaml doesn't do anything very different from C programs. I suggest
        that you 'strace' your program to see what actual system call it is
        making (ie. to open(2)) and then look at the manpage for open(2).

        Rich.

        --
        Richard Jones
        Red Hat
      • Ashish Agarwal
        ... I ve tried compiling to native and byte code. Same results. ... let cout = open_out a.txt let _ = output_string cout hello ; close_out cout ... let _ =
        Message 3 of 8 , Jul 1, 2008
          > Are you running this from an ocaml interactive session, compiling it
          > with ocamlc, or compliling it with ocamlopt?

          I've tried compiling to native and byte code. Same results.

          > Are you using any sort of helper scripts
          > What does "roughly" mean? Can you show the whole code?
          Actually, I just reproduced the problem with the following minimal program:

          --- prog.ml ---
          let cout = open_out "a.txt"
          let _ =
          output_string cout "hello";
          close_out cout


          Rewriting the code as below gives the same problems:

          --- prog2.ml ---
          let _ =
          let cout = open_out "a.txt" in
          output_string cout "hello";
          close_out cout

          This is only happening on a RedHat Enterprise Linux system. I do not have
          the problem on my Mac OS X.

          > I suggest that you 'strace' your program

          Thanks, I have never done that but I will look into it.



          On Tue, Jul 1, 2008 at 4:43 AM, Richard Jones <rich@...> wrote:

          > On Mon, Jun 30, 2008 at 07:24:10PM -0400, Ashish Agarwal wrote:
          > > I'm having a strange problem. My program deletes files created by a
          > previous
          > > invocation even though I'm changing the file name! My program is roughly
          > the
          > > following:
          > > let open_out_safe = open_out_gen [Open_wronly; Open_creat; Open_excl;
          > > Open_text] 0o666
          >
          > OCaml doesn't do anything very different from C programs. I suggest
          > that you 'strace' your program to see what actual system call it is
          > making (ie. to open(2)) and then look at the manpage for open(2).
          >
          > Rich.
          >
          > --
          > Richard Jones
          > Red Hat
          >
          >
          >


          [Non-text portions of this message have been removed]
        • Oliver Bandel
          Hello, ... Well... both programs use normal open_out. The special stuff you mentioned in your first mail is not here now... so you threw it out, or maybe never
          Message 4 of 8 , Jul 1, 2008
            Hello,



            Zitat von Ashish Agarwal <agarwal1975@...>:

            > > Are you running this from an ocaml interactive session, compiling
            > it
            > > with ocamlc, or compliling it with ocamlopt?
            >
            > I've tried compiling to native and byte code. Same results.
            >
            > > Are you using any sort of helper scripts
            > > What does "roughly" mean? Can you show the whole code?
            > Actually, I just reproduced the problem with the following minimal
            > program:
            >
            > --- prog.ml ---
            > let cout = open_out "a.txt"
            > let _ =
            > output_string cout "hello";
            > close_out cout
            >
            >
            > Rewriting the code as below gives the same problems:
            >
            > --- prog2.ml ---
            > let _ =
            > let cout = open_out "a.txt" in
            > output_string cout "hello";
            > close_out cout


            Well... both programs use normal open_out.
            The special stuff you mentioned in your first mail
            is not here now... so you threw it out, or maybe never had it inside
            your first code.

            Overwriting without any erors/exceptions is normal behaviour,
            so I don't know what you do expect.


            It seems you eat a bread and want that it tastes like pizza.
            I would assume, there is a difference in taste. But maybe I missed
            something
            and you can elaborate more on this.





            >
            > This is only happening on a RedHat Enterprise Linux system. I do not
            > have
            > the problem on my Mac OS X.


            What problem do you have?

            I mean: what problems do you have with the above code, and did you
            really compiled the above code on those systems you mentioned?


            Ciao,
            Oliver
          • Ashish Agarwal
            Sorry for wasting everyone s time... there was some file syncing utility running that kept deleting files behind me. On Tue, Jul 1, 2008 at 7:35 PM, Oliver
            Message 5 of 8 , Jul 1, 2008
              Sorry for wasting everyone's time... there was some file syncing utility
              running that kept deleting files behind me.


              On Tue, Jul 1, 2008 at 7:35 PM, Oliver Bandel <oliver@...-berlin.de>
              wrote:

              > Hello,
              >
              > Zitat von Ashish Agarwal <agarwal1975@... <agarwal1975%40gmail.com>
              > >:
              >
              > > > Are you running this from an ocaml interactive session, compiling
              > > it
              > > > with ocamlc, or compliling it with ocamlopt?
              > >
              > > I've tried compiling to native and byte code. Same results.
              > >
              > > > Are you using any sort of helper scripts
              > > > What does "roughly" mean? Can you show the whole code?
              > > Actually, I just reproduced the problem with the following minimal
              > > program:
              > >
              > > --- prog.ml ---
              > > let cout = open_out "a.txt"
              > > let _ =
              > > output_string cout "hello";
              > > close_out cout
              > >
              > >
              > > Rewriting the code as below gives the same problems:
              > >
              > > --- prog2.ml ---
              > > let _ =
              > > let cout = open_out "a.txt" in
              > > output_string cout "hello";
              > > close_out cout
              >
              > Well... both programs use normal open_out.
              > The special stuff you mentioned in your first mail
              > is not here now... so you threw it out, or maybe never had it inside
              > your first code.
              >
              > Overwriting without any erors/exceptions is normal behaviour,
              > so I don't know what you do expect.
              >
              > It seems you eat a bread and want that it tastes like pizza.
              > I would assume, there is a difference in taste. But maybe I missed
              > something
              > and you can elaborate more on this.
              >
              > >
              > > This is only happening on a RedHat Enterprise Linux system. I do not
              > > have
              > > the problem on my Mac OS X.
              >
              > What problem do you have?
              >
              > I mean: what problems do you have with the above code, and did you
              > really compiled the above code on those systems you mentioned?
              >
              > Ciao,
              > Oliver
              >
              >
              >


              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.