Making a script write to a file (take 2)

Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default Making a script write to a file (take 2)

    G'day all

    I'm trying to get a script to write (append) data to the bottom line
    of a text file (*.dat). I know the variables I want to add but can't
    do it.
    I need to append something that looks like this...

    $invoice|$date|Your Order has been received

    Any suggestions would be helpful.

    Cheers
    Dave.
    Dave Guest

  2. Similar Questions and Discussions

    1. Script Error after making changes
      First, I am not a website designer. I own a website and have been making minor (text) changes using Contribute since I didn't need to know html. I...
    2. PDF-making Script
      Is there a script to get pdfs made automatically? Currently, I am making pdfs by processing ad after ad by making a ps file and then dragging it into...
    3. Is it possible Write Script for text field in Illustrator?
      Is it possible Write Script (condition) for text field in Illustrator 10? Is it possible to make any script that would check the date, or require...
    4. edit and write multiple files with ed/ed/vi script
      On 10 Aug 2003 18:30:59 -0700, chris <chris_piechowicz@hotmail.com> wrote: Hi, I am not quite sure if ed/ex/vi is the right tool for this job. I...
  3. #2

    Default Re: Making a script write to a file (take 2)

    Dave wrote:
    > G'day all
    >
    > I'm trying to get a script to write (append) data to the bottom line
    > of a text file (*.dat). I know the variables I want to add but can't
    > do it.
    > I need to append something that looks like this...
    >
    > $invoice|$date|Your Order has been received
    >
    > Any suggestions would be helpful.
    Is it possible that multiple processes add at the same time?

    --
    Kind regards, feel free to mail: mail(at)johnbokma.com (or reply)
    virtual home: [url]http://johnbokma.com/[/url] ICQ: 218175426
    John web site hints: [url]http://johnbokma.com/websitedesign/[/url]

    John Bokma Guest

  4. #3

    Default Re: Making a script write to a file (take 2)

    [email]prometheus_au@excite.com.au[/email] (Dave) wrote in
    news:526e114e.0309041747.7f0ec8aa@posting.google.c om:
    > G'day all
    >
    > I'm trying to get a script to write (append) data to the bottom line
    > of a text file (*.dat). I know the variables I want to add but can't
    > do it.
    > I need to append something that looks like this...
    >
    > $invoice|$date|Your Order has been received
    >
    > Any suggestions would be helpful.
    Read perldoc perlopentut

    open OUT, ">> file.dat" or die "Could not open file.dat : $!";

    print OUT "$invoice|$date|Your Order has been received\n";

    close OUT;



    Lao
    Lao Coon Guest

  5. #4

    Default Re: Making a script write to a file (take 2)

    Dave (prometheus_au@excite.com.au) wrote on MMMDCLVII September MCMXCIII
    in <URL:news:526e114e.0309041747.7f0ec8aa@posting.goo gle.com>:
    // G'day all
    //
    // I'm trying to get a script to write (append) data to the bottom line
    // of a text file (*.dat). I know the variables I want to add but can't
    // do it.
    // I need to append something that looks like this...
    //
    // $invoice|$date|Your Order has been received
    //
    // Any suggestions would be helpful.


    What have you tried so far?


    Abigail
    --
    sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==> "$A$Y".
    "$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=* _;sub _{print+/.*::(.*)/s};;;
    *_'_=*{chr($b*$e)};*__=*{chr(1<<$e)}; # Perl 5.6.0 broke this...
    _::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t( us(J())))))))))))))))))))))))
    Abigail Guest

  6. #5

    Default Re: Making a script write to a file (take 2)

    Abigail <abigail@abigail.nl> wrote in message news:<slrnblgksg.6g7.abigail@alexandra.abigail.nl> ...
    >
    > What have you tried so far?
    >
    >
    > Abigail
    Abigail,

    I've been working on this.....

    $orders_dat = "http//....path to file"

    open(ORDERS,">>$orders_dat"); print ORDERS
    "$invoice$delimiter$date$delimiter$processing_msg\ n"; close(ORDERS);

    Cheers
    Dave.
    Dave Guest

  7. #6

    Default Re: Making a script write to a file (take 2)

    Dave <prometheus_au@excite.com.au> wrote:
    > Abigail <abigail@abigail.nl>
    >>
    > I've been working on this.....
    >
    > $orders_dat = "http//....path to file"
    >
    > open(ORDERS,">>$orders_dat"); print ORDERS
    > "$invoice$delimiter$date$delimiter$processing_msg\ n"; close(ORDERS);
    open() doesn't accept urls as arguments. If the file is on a remote
    system you can't use open().

    If this is cgi, you must remember to lock your files. Otherwise
    simultaneous updates might ruin your files. See 'perldoc -f flock'
    for details on how to do this.

    Regards,
    --
    Vlad
    Vlad Tepes Guest

  8. #7

    Default Re: Making a script write to a file (take 2)

    > $orders_dat = "http//....path to file"

    that's your problem. you need to use the real system path to the
    file, not it's HTTP URL.
    Philip Guest

  9. #8

    Default Re: Making a script write to a file (take 2)

    [email]drew@perlmad.com[/email] (Philip) wrote in message news:<9826ff94.0309092008.35913517@posting.google. com>...
    > > $orders_dat = "http//....path to file"
    >
    > that's your problem. you need to use the real system path to the
    > file, not it's HTTP URL.
    so if I change it to....

    $orders_dat = "/home/user/public_html/web/orders.dat"

    open(ORDERS,">>$orders_dat");
    print ORDERS
    "$invoice$delimiter$date$delimiter$processing_msg\ n"; close(ORDERS);

    It should work! I'll give it a whirl.
    Thanks for the constructive criticism!

    Dave.
    Dave Guest

  10. #9

    Default Re: Making a script write to a file (take 2)

    >> On 11 Sep 2003 18:22:52 -0700,
    >> [email]prometheus_au@excite.com.au[/email] (Dave) said:
    > [email]drew@perlmad.com[/email] (Philip) wrote in message
    > news:<9826ff94.0309092008.35913517@posting.google. com>...
    >> > $orders_dat = "http//....path to file"
    >>
    >> that's your problem. you need to use the real system
    >> path to the file, not it's HTTP URL.
    (An http URL does not refer to a file.)
    > so if I change it to....
    > $orders_dat = "/home/user/public_html/web/orders.dat"
    > open(ORDERS,">>$orders_dat"); print ORDERS
    > "$invoice$delimiter$date$delimiter$processing_msg\ n";
    > close(ORDERS);
    > It should work! I'll give it a whirl. Thanks for the
    > constructive criticism!
    Don't forget you have to deal with locking.

    perldoc -q lock

    hth
    t
    Tony Curtis Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139