Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

text file w/o CGI

by spunkcell (Initiate)
on Apr 05, 2001 at 05:12 UTC ( #69968=perlquestion: print w/replies, xml ) Need Help??

spunkcell has asked for the wisdom of the Perl Monks concerning the following question:

I'm a newbie to PERL, use ASP and CF. I need to write a script that adds text to a text file from a HTML form. Basically adds theri name and email they've entered to a txt file. I can't use CGI on this server. Any ideas? Thanks.

Replies are listed 'Best First'.
(crazyinsomniac) Re: text file w/o CGI
by crazyinsomniac (Prior) on Apr 05, 2001 at 05:31 UTC
    I'm not suprised one bit by the responses you got.

    I agree with all of them.

    It is ill-advised to attempt to process form data, without the CGI module.

    Why you might ask, cause it was written for that particular task, and it does it's job well, and it's fairly large....

    It is not impossible, but it's the #1 Cardinal sin, next to not using -w and strict.

    And if your server does not allow CGI, then you really have some problems.

    Do a search on 'CGI' and look at the Q&A and even the Tutorials section, as this is a common question.

     
    ___crazyinsomniac_______________________________________
    Disclaimer: Don't blame. It came from inside the void

    perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

      Thanks everybody. Great answers. I think the web administrator of the company we are contracting to is trying to be funny. Oh well, I'll try to find another way to get those things to a file. They use Vignette and I was told I could only use PERL without CGI and couldn't access CGI's outside the server. But I need to get these names and emails to a list somehow. Thanks again for the great and fast responses. I may have to learn PERL if the communities are this helpful.

        If you're living in a Vignette enviroment, you can (ab)use perl without doing so via CGI by running it with something like [exec /usr/bin/perl ...] (IIRC), but that's an extremely kludgey solution and bound to give you more grief than is worth.

        Why not just use native Vignette and Tcl commands to do what you want? My Vignette/Tcl is a bit rusty, but something along the following lines should work ...

        [SET file [open /path/to/my/file.txt a]] [puts $file "[SHOW name] [SHOW email]"]

        (Error checking left as an exercise for the reader. :-)

            --k.


Re: text file w/o CGI
by davorg (Chancellor) on Apr 05, 2001 at 13:43 UTC

    Reading thru the responses you've recieved, it seems that people are interpreting your question in two different ways.

    1. You can't run any CGI scripts on your web server.
    2. You can't use CGI.pm on your web server.

    Perhaps you could clarify which of those you mean.

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

Re: text file w/o CGI
by KM (Priest) on Apr 05, 2001 at 05:15 UTC
    I can't use CGI on this server. Any ideas?

    Yes, get a new server (account, or whatever). HTML can not write thinks to files.

    Cheers,
    KM

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: text file w/o CGI
by extremely (Priest) on Apr 05, 2001 at 08:44 UTC
    One more possibility. Have the form post by e-mail. Then have a perl script read the mail box every so often and write the text file. No CGI that way but you'll need the root user/Administrator to set up a cron/scheduled job to run the perl script every so often.

    And, of course, if you had a helpful root/admin you wouldn't have this problem in the first place. =) But I wanted to point out your problem is solvable with perl and some ingenuity!

    --
    $you = new YOU;
    honk() if $you->love(perl)

      Please keep in mind that having the form mailed has to be supported by the browser - and that's not possible in every browser that is around (and used, of course :). So if you really want to use that keep in mind that it won't work for everybody!
      --
      Alfie
Re: text file w/o CGI
by Caillte (Friar) on Apr 05, 2001 at 16:54 UTC

    What server do you use? Does it allow Server Side Includes? If that is the case, try using perlscript or similar

    $japh->{'Caillte'} = $me;

(dws - clarify!)Re: text file w/o CGI
by dws (Chancellor) on Apr 05, 2001 at 21:08 UTC
    Update: davorg posts a nearly identical question above. I'd given up in frustration and posted mine before seeing his. The only value this ads is option (C) below.

    spunkcell, it's time to clarify something.

    When you say "I can't use CGI on this server," do you mean

    A. I am not allowed to use CGI scripts, or
    B. I am not allowed to use CGI.pm
    People above seemed to have assumed one of these or the other, leading two vastly divergent opinions on how to address your problem.

    Or do you mean

    C. I am not allowed to use my own CGIs, and must use the ones that are already present.
      Wow, you guys are great.
      I admit I'm not sure if I can't use the CGI.pm or are not allowed to use CGI scripts.
      Here is our email coversation;
      ME to their cto-
      "I'm the programmer that will be working with Scott and Ryan on the CBOT investors floor tutorial. I'll be setting up our test box today and was wondering which version of Solaris you use. I also would like to know which web languages we can use on your servers in the finished version (PHP, Perl, etc.)."
      Him-
      "solaris 2.7 and perl would be the only choice BUT we don't run it as a CGI and will not allow CGI access from the outside. What were you thinking of doing? Just curious..."
      Hope that can clear things up some, I really apreciate everyone's help.
        The CTO has told you what they don't allow, but he hasn't told you what they do allow. Note the word "allow". It suggests "policy", and policies can often be influenced (i.e., changed) in response to business needs. If your business need involves adding dynamic web content to their web server, and they don't allow that, then this may need to get escalated to (I'm guessing) the sponsor of the "CBOT investors floor" project so that they can influence policy at a higher level (e.g., by negotiating with the CTO or the CTO's boss).

        A good next step is to explain to the CTO what your project needs are, and ask him to suggest options. This puts him in the position of working with you, rather than blocking you. He's already given you the opening by asking what you're trying to accomplish. Take that opening.

Re: text file w/o CGI
by Xxaxx (Monk) on Apr 05, 2001 at 12:33 UTC
    At the risk of being shunned and excommunicated by the more catholic of the monks I can say from experience that it is possible to live without the CGI module.

    When I started my scripts all I was allowed on the server was Perl and a few standard modules (CGI was stripped for some unaccountable reason). I was forced to learn a little more about handling forms than I might have wanted at the time but I was able to survive.

    Claude

    Update It didn't take long for the --'s to start pouring in. ;-)

      The monks who are --'ing you fall in two categories:
      1. Monks who have really studied CGI and know the problems of "hand-rolled" CGI parsing.
      2. Monks who trust those who claim to be in the first category.
      While I admit that I am no Perl guru, I definitely fall in the first category. Suggesting to someone that they can "live without the CGI module" is dangerous. The implication, if the statement is unqualified, suggests that it's okay to not use CGI.pm. Unfortunately, no one should go down that road unless the know exactly what they are doing, but the monk in question specifically stated that /s?he/ was new to Perl.

      I'll make you a deal. Post your CGI handling code and if I can't point out the problems with it, I will offer you my humblest apologies and acknowledge that you are a genius.

      I'm not trying to be rude and I hope you don't take it this way, but I am very dismayed when I see people try to suggest alternatives without a very clear reason why.

      Cheers,
      Ovid

      Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

        I don't take your comments as rude in the slightest.
        But when some poor schmuck is stuck on a server (for reasons which may not be easily altered) which does not have CGI.pm (for god knows why) perhaps something better than "give up and go hunting for a new ISP" would be useful.

        His problem is relatively straight forward. It's not like he's trying to do file uploads. Capturing a few variables, parsing them, etc.

        Is it better to use CGI? You bet your sweet behind.
        Are there situations in which CGI just doesn't exist? Apparently.
        Should it be possible to at least limp along in those situations? I think it should.

        When a module exists that performs some function, and that module is so standard that it's part of the basic Perl install, it's a good idea to use the module.

        But when someone clearly indicates that given their situation the module is not available, perhaps an alternative to 'move' would be useful. That's my only point.

        And since I was there and did manage to make it work until such time as I was able to move to a better server I felt perhaps a little "You can get by" encouragement might be better than 100% give up and move.

        Is it better to use CGI? You bet. But when you can't for whatever reason life still goes on and it is still possible to get some work done.

        Claude

      Of course you don't have to use CGI.pm to write CGI scripts. The point is, however, that there is no good reason not to do so. If your server doesn't have CGI.pm installed then you either have a very old version of Perl (in which case you should upgrade) or a web server administrator who is in need of some education.

      --
      <http://www.dave.org.uk>

      "Perl makes the fun jobs fun
      and the boring jobs bearable" - me

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://69968]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2022-07-04 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?