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

Hi: Script (faked identities) called from link works fine.
https://www.dumpledorf.us/httpsdocs/cgi-bin/update_tables.cgi?action +=updatetable_433
Also works fine called from website page. I want to call the scripts via FTP from a different program. Five variations of the subs called with this cgi updatetable_443, _444, _445, _446 and _447 First three call subs that delete all data from MySQL Tables and replace with uploaded txt file data. Other two download a dynamically created HTML table. All this works fine when called from website page and links I put in email to test. Question: Can you call(execute) a cgi-script with an FTP command of some sort. I have looked at many. None seem appropriate. I tried ftp.literal with different commands. No luck Alternatives appreciated. For the latter two I don't want to open a default browser loaded with the URL. I want to try all using FTP .htaccess AddHandler cgi-script .cgi .pl Options +ExecCGI Secondary question ( not remotely perl related), the ftp.put result for the (16k and 300k)txt files appear truncated on the server at 1440 and 2880 bytes. Sources are fine. ft = binary. Any hints there?

Replies are listed 'Best First'.
Re: Call CGI Scr.ipt via FTP
by dsheroh (Monsignor) on Aug 19, 2018 at 09:36 UTC
    I've never heard of an FTP server with any capabilities that are even vaguely CGI-like. I suppose you could (very) roughly approximate it by having a directory where users can upload a text file containing a request and a cron job which checks that directory for request files and, if it finds any, processes the request and writes an output file, which the user can then download. But I doubt you're likely to get much closer than that without using a heavily-patched server (and probably a customized client as well) to add the CGI-like features.
      I've never heard of an FTP server with any capabilities that are even vaguely CGI-like.

      I remember some embedded device that could get a firmware update via FTP (FTP upload to a special name). That's quite common, you can do that with many printservers and other embedded devices. But that device could also be rebooted by writing to another special name.

      I suppose you could (very) roughly approximate it by having a directory where users can upload a text file containing a request and a cron job which checks that directory for request files and, if it finds any, processes the request and writes an output file, which the user can then download.

      inotify, dnotify, and other filesystem notification systems should be more efficient than a cron job.

      But I doubt you're likely to get much closer than that without using a heavily-patched server (and probably a customized client as well) to add the CGI-like features.

      You could also make the ftp server access a FUSE filesystem to implement tons of magic in that filesystem. And you could get the same magic via NFS or Samba as well.

      Plus, there is also a (mandatory) SITE command in FTP, that can implement site-specific commands. Several FTP servers implement SITE EXEC <command> to run an external executable. SITE CHMOD is also quite common.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: Call CGI Scr.ipt via FTP
by Anonymous Monk on Aug 19, 2018 at 07:04 UTC

    Executing scripts isn't something that's defined in the protocol, so you would have to patch the FTP server (and client, likely) and implement a non-standard command (or non-standard behaviour as response to standard command) if you decide to go that way.

    Have you considered SSH? You can have both command execution and file transfer (also secured with asymmetric cryptography, unlike standard FTP without TLS).

Re: Call CGI Scr.ipt via FTP
by tultalk (Monk) on Aug 18, 2018 at 21:36 UTC
    Actually this is not perl related at all. I will find different forum to post these questions. Sorry. Lost my mind

      G'day tultalk,

      "Actually this is not perl related at all."

      Well, the OP contains "... AddHandler cgi-script .cgi .pl ...", so perhaps some relationship, albeit highly tenuous, exists. Please mark your OP as OT.

      Also, please do not post code, data, and the like, as paragraph text: wrap it in <code>...</code>. For example, consider the improved readability if you had used something like:

      AddHandler cgi-script .cgi .pl Options +ExecCGI

      instead of that just appearing embedded in the text: "... using FTP .htaccess AddHandler cgi-script .cgi .pl Options +ExecCGI Secondary ..." [sic].

      — Ken