Net::FTP problem

Discussion in 'Perl Misc' started by lain, Jul 8, 2005.

  1. lain

    lain Guest

    Hi all,

    I have big trouble on Net::FTP, could you please give me some idea??

    My ftp server is on Win2K Prof, IIS.

    First, I tried ftp on my linux server , it works fine.

    Then I created a cgi script, run the script manually on linux server,
    to get the file from that Win2K and put on my linux server, it works
    fine too.

    However, while i was on my php web system, submit the php POST to the
    cgi-script, it show me the internal error.
    I go to error log, it shows me the error:
    cant open the file, permission denied.

    I really do not know what's wrong, is it my ftp problem? coding
    problem or network prob??

    1. i have set the full permission on ftp folder in win2k.
    2. chmod 777 on my cgi-script
    3. the ftp folder located in C://inetpub/ftproot/test (created as
    virtual directory)

    any suggestions, comments, helps are all welcomed.
    I'm going to try an alternative to do the task.

    Thanks a lot!!
     
    lain, Jul 8, 2005
    #1
    1. Advertising

  2. On Fri, 08 Jul 2005 00:31:30 -0700, lain wrote:

    > Hi all,
    >
    > I have big trouble on Net::FTP, could you please give me some idea??
    >
    > My ftp server is on Win2K Prof, IIS.
    >
    > First, I tried ftp on my linux server , it works fine.
    >
    > Then I created a cgi script, run the script manually on linux server,
    > to get the file from that Win2K and put on my linux server, it works
    > fine too.
    >
    > However, while i was on my php web system, submit the php POST to the
    > cgi-script, it show me the internal error.
    > I go to error log, it shows me the error:
    > cant open the file, permission denied.


    I'm not sure I followed your explanation properly, but I figure that you
    are trying to pull a file from a Win2K FTP server to a Linux box by
    submitting to a cgi script (which uses NET::FTP to get the file) on the
    Linux box from a web-browser? If so, then you need to understand that cgi
    scripts run as a specific user, usually apache or httpd and that 99 times
    out of a 100 this user doesn't have write permission to the file's
    destination, as per the error message you are seeing. You must fix this by
    either 1) having the script write the file somewhere it already has
    permission or 2) change the permissions where it is trying to write so
    that it can.

    HTH
    Rich
     
    Richard Gration, Jul 8, 2005
    #2
    1. Advertising

  3. lain

    lain Guest

    Richard Gration <> wrote in message news:<>...
    > On Fri, 08 Jul 2005 00:31:30 -0700, lain wrote:
    >
    > > Hi all,
    > >
    > > I have big trouble on Net::FTP, could you please give me some idea??
    > >
    > > My ftp server is on Win2K Prof, IIS.
    > >
    > > First, I tried ftp on my linux server , it works fine.
    > >
    > > Then I created a cgi script, run the script manually on linux server,
    > > to get the file from that Win2K and put on my linux server, it works
    > > fine too.
    > >
    > > However, while i was on my php web system, submit the php POST to the
    > > cgi-script, it show me the internal error.
    > > I go to error log, it shows me the error:
    > > cant open the file, permission denied.

    >
    > I'm not sure I followed your explanation properly, but I figure that you
    > are trying to pull a file from a Win2K FTP server to a Linux box by
    > submitting to a cgi script (which uses NET::FTP to get the file) on the
    > Linux box from a web-browser? If so, then you need to understand that cgi
    > scripts run as a specific user, usually apache or httpd and that 99 times
    > out of a 100 this user doesn't have write permission to the file's
    > destination, as per the error message you are seeing. You must fix this by
    > either 1) having the script write the file somewhere it already has
    > permission or 2) change the permissions where it is trying to write so
    > that it can.
    >
    > HTH
    > Rich



    Hi Rich,

    Could you please explain in detail??
    See, I've chmod 777 to the cgi script. Would that still not enough??
    I've considered maybe it cant write anything on cgi-bin directory, coz
    from the Net::FTP module, I've learnt that the retrieved file would
    'temporary' located at the current working directory.
    But While i run the script manually it works, never show the error
    message and i can put the file to another directory after.
    Or while i GET the file i should force it to store on another
    directory??
    I'd done like this:
    $ftp->GET("the file i want to retrieve", "the location i want to put
    temporary of the file");
    ie : $ftp->GET("image.jpg", "http://231.12.255.1/folder/image.jpg");
    But it showed me the error : couldnt find the file.

    Hear from you Rich!!
     
    lain, Jul 10, 2005
    #3
  4. lain

    lain Guest

    John Mason Jr <> wrote in message news:<>...
    > lain wrote:
    > > Hi all,
    > >
    > > I have big trouble on Net::FTP, could you please give me some idea??
    > >
    > > My ftp server is on Win2K Prof, IIS.
    > >
    > > First, I tried ftp on my linux server , it works fine.
    > >
    > > Then I created a cgi script, run the script manually on linux server,
    > > to get the file from that Win2K and put on my linux server, it works
    > > fine too.
    > >
    > > However, while i was on my php web system, submit the php POST to the
    > > cgi-script, it show me the internal error.
    > > I go to error log, it shows me the error:
    > > cant open the file, permission denied.
    > >
    > > I really do not know what's wrong, is it my ftp problem? coding
    > > problem or network prob??
    > >
    > > 1. i have set the full permission on ftp folder in win2k.
    > > 2. chmod 777 on my cgi-script
    > > 3. the ftp folder located in C://inetpub/ftproot/test (created as
    > > virtual directory)
    > >
    > > any suggestions, comments, helps are all welcomed.
    > > I'm going to try an alternative to do the task.
    > >
    > > Thanks a lot!!

    >
    >
    > Make sure your directory listing style is Unix not MS-DOS on the IIS FTP
    > server
    >
    >
    > John



    Hi John,

    That's correct, the directory listing was MS-DOS on my FTP server.
    Then I changed to Unix, but it doesnt work...still the same error
    message : permission denied T_T
    Do you have ny other idea??
     
    lain, Jul 10, 2005
    #4
  5. lain

    lain Guest

    (lain) wrote in message news:<>...
    > John Mason Jr <> wrote in message news:<>...
    > > lain wrote:
    > > > Hi all,
    > > >
    > > > I have big trouble on Net::FTP, could you please give me some idea??
    > > >
    > > > My ftp server is on Win2K Prof, IIS.
    > > >
    > > > First, I tried ftp on my linux server , it works fine.
    > > >
    > > > Then I created a cgi script, run the script manually on linux server,
    > > > to get the file from that Win2K and put on my linux server, it works
    > > > fine too.
    > > >
    > > > However, while i was on my php web system, submit the php POST to the
    > > > cgi-script, it show me the internal error.
    > > > I go to error log, it shows me the error:
    > > > cant open the file, permission denied.
    > > >
    > > > I really do not know what's wrong, is it my ftp problem? coding
    > > > problem or network prob??
    > > >
    > > > 1. i have set the full permission on ftp folder in win2k.
    > > > 2. chmod 777 on my cgi-script
    > > > 3. the ftp folder located in C://inetpub/ftproot/test (created as
    > > > virtual directory)
    > > >
    > > > any suggestions, comments, helps are all welcomed.
    > > > I'm going to try an alternative to do the task.
    > > >
    > > > Thanks a lot!!

    > >
    > >
    > > Make sure your directory listing style is Unix not MS-DOS on the IIS FTP
    > > server
    > >
    > >
    > > John

    >
    >
    > Hi John,
    >
    > That's correct, the directory listing was MS-DOS on my FTP server.
    > Then I changed to Unix, but it doesnt work...still the same error
    > message : permission denied T_T
    > Do you have ny other idea??


    Hi all,

    I'd solved the problem already!!
    I would like to answer here in case somebody else need the reference
    in future, as me, I searched many similar topic but without the proper
    answer!!
    Maybe there got something else can solve it out, but this is my
    solution :

    First, the reason I got the 'permission denied' while i run my cgi
    script on the browser is because I act as end user, not the root as
    well.

    Read from the Net/FTP.pm, when you get the file, it would store the
    file in the current directory,in case if you haven't specified the
    location. Therefore it would store in the cgi-bin folder, and do you
    think it is possible?? :D (MUST read the module file properly, while i
    havent read detail b4 :p)

    So I'd made this :

    1. create a folder in public_html, lets say 'temp' (havent tried out
    if can store the file besides public_html, but i think possibly can)
    2. chmod 777 temp ( i m not that sure if 755 is enough)

    my code:
    $ftp->get("file1.txt", "/home/server/public_html/temp/file1.txt");

    before i was trying to locate it as "../public_html/temp", but it is
    really bad idea!

    simple right??

    Anyway, i do believe there got better solution out there. If you do
    have any comments and anything else, please share with me :)
     
    lain, Jul 13, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    5,647
  2. Vin Raja

    FTP : Time problem (net/ftp)

    Vin Raja, Jun 7, 2007, in forum: Ruby
    Replies:
    0
    Views:
    102
    Vin Raja
    Jun 7, 2007
  3. Ari Brown

    Net::FTP and ftp.dir()

    Ari Brown, Jul 16, 2007, in forum: Ruby
    Replies:
    0
    Views:
    88
    Ari Brown
    Jul 16, 2007
  4. Jeff Miller
    Replies:
    0
    Views:
    501
    Jeff Miller
    Mar 26, 2009
  5. D. Buck
    Replies:
    2
    Views:
    489
    D. Buck
    Jun 29, 2004
Loading...

Share This Page