Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: cgi project

  1. #1
    New to the CF scene
    Join Date
    Sep 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cgi project

    I am trying to write some cgi code that will allow users to login and then put a URL into a form which will then get the file from that form and put it into their home directory on a linux server. I have the login part down using apache authentication. I can get their user name with $remote_user = $ENV{REMOTE_USER} and display it using print "$remote_user" Now I just need to know how to get them logged into the unix shell, how to get the file. I want to use wget, but I'm new to perl/cgi and unix commands dont seem to be working. I am just doing some testing and trying to do system("touch filename") to see if things are working. That never works. Can someone help me get started?


    Thanks

    Jeff

  • #2
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    What you can try doing first is trying to make another cgi that gets the file, opens it, writes it, saves it, and closes it. If you can get this to go, then trying to incorporate login to the linux will be the next hardest task. Forget the login at first. You need two CGI scripts, i recommend. 1 for login, and the second for File handling within the system. Let me know if you need help with file handling. i will try to make a script for you or tell you how to do it.

    email me [at] burninator96[at]msn.com
    ***make sure you change the [at].

  • #3
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    This script will allow you to save only, so when you make your form, you will have to make the form variable comply with a similar script to this.


    #!/usr/bin/perl -w

    open(Source,"THISFILE" || die "opening THISFILE: $!";

    while(defined($a=<Source>)) {
    print $a;
    }


    open(Destination, ">THISFILE.txt") || die ":$!";
    if (! print Destination "This entry was written at", scalar(localtime), "\n" ) {
    warn "unable to write to this file: $!" ;

    @contents=<Source>;
    print Destination @contents;

    Variables
    print Destination @variable ;
    The above line will add your variable to the destination file. All you have to do is copy the line and change the variable name.


    close(Source) ;
    close(Destination) ;




    If you have confusion let me know and i will create the cgi script and all you have to do is supply the directory information, the file name and what you want it to do.
    Last edited by Web_eng_master; 10-19-2004 at 06:55 PM.


  •  

    Posting Permissions

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