FileUpload auf Client automatisieren
Sven Rudolph
- cgi
0 FrankS0 Sven Rudolph0 FrankS
Hallo an alle!
Ich habe folgendes Problem. Ich moechte ein Bild mehrmals
taeglich per http-upload von einem Clientrechner auf meinem Server
ablegen. Das PHP3-Script welches die Bilddatei annimmt und auf dem
Server abspeichert ist fertig und funktioniert einwandfrei.
Nun moechte ich aber den Upload nicht immer von Hand ausfuehren,
sondern von einem Script erledigen lassen (auf dem Client Rechner
laeuft Linux).
Kann mir jemand einen Tipp geben, wie ich dieses Problem am besten
angehen kann? Ich habe daran gedacht den Lynx dafuer zu verwenden.
Vielen Dank im voraus!
Sven Rudolph
Hallo Sven!
Nun moechte ich aber den Upload nicht immer von Hand ausfuehren,
sondern von einem Script erledigen lassen (auf dem Client Rechner
laeuft Linux).
Zyklische Aktionen lassen sich einem cronjob abhandeln (man crontab). Schreibe Dir ein Script (z.B. in Perl), das vom cron job zyklisch angeworfen wird und die Daten zum Server sendet. Das kannst Du dann natürlich auch gleich per ftp und einem shellscript machen.
Gruß Frank
Zyklische Aktionen lassen sich einem cronjob abhandeln (man crontab).
Schreibe Dir ein Script (z.B. in Perl), das vom cron job
zyklisch angeworfen wird und die Daten zum Server sendet. Das kannst
Du dann natürlich auch gleich per ftp und einem shellscript machen.
Gruß Frank
Hallo Frank
Vielen Dank fuer Deine Antwort
Das ich das Script schlussendlich als Cronjob laufen lasse ist klar.
Mir ging es darum zu erfahren, wie ich in einem Script (Perl, Shellscript
oder was auch immer) einen http-Upload realisiere (ftp faellt Flach).
Gibt es in Perl dafuer vorgefertigte Funktionen? (Wahrscheinlich ja)
Kennst Du Manuals, Docs, Howtos, Beispiele die ich dafuer lesen sollte?
Vielen Dank
Sven Rudolph
Hallo Sven!
Das ich das Script schlussendlich als Cronjob laufen lasse ist klar.
dacht ich mir...
»» (ftp faellt Flach).
Warum? Es gibt auch für FTP im Perl Module. Und einen Kommadozeilen-FTP-Client kann man doch auch so schön per commadfile steuern:
ftp -s:ftpcmd
und in ftpcmd steht:
open DeinHost
username
password
chdir irgendwas
put file
bye
Gibt es in Perl dafuer vorgefertigte Funktionen? (Wahrscheinlich ja)
Ja, auch dafür gibts Module. Ich kopiere einfach mal ein Auszug aus Perl in a Nutshell:
<cite>
17.3 The HTTP Modules
The HTTP modules implement an interface to the HTTP messaging protocol used in web transactions. Its most useful modules are HTTP::Request and HTTP::Response,
which create objects for client requests and server responses. Other modules provide means for manipulating headers, interpreting server response codes, managing
cookies, converting date formats, and creating basic server applications.
Client applications created with LWP::UserAgent use HTTP::Request objects to create and send requests to servers. The information returned from a server is saved as
an HTTP::Response object. Both of these objects are subclasses of HTTP::Message, which provides general methods of creating and modifying HTTP messages. The
header information included in HTTP messages can be represented by objects of the HTTP::Headers class.
HTTP::Status includes functions to classify response codes into the categories of informational, successful, redirection, error, client error, or server error. It also exports
symbolic aliases of HTTP response codes; one could refer to the status code of 200 as RC_OK and refer to 404 as RC_NOT_FOUND.
17.3.1 HTTP::Request
This module summarizes a web client's request. For a simple GET request, you define an object with the GET method and assign a URL to apply it to. Basic headers
would be filled in automatically by LWP. For a POST or PUT request, you might want to specify a custom HTTP::Headers object for the request, or use the
contents of a file for an entity body. Since HTTP::Request inherits everything in HTTP::Message, you can use the header and entity body manipulation methods from
HTTP::Message in HTTP::Request objects.
The constructor for HTTP::Request looks like this:
$req = http::Request->new (method, url, [$header, [content]]);
The method and URL values for the request are required parameters. The header and content arguments are not required, nor even necessary for all requests. The
parameters are described as follows:
method
A string specifying the HTTP request method. GET, HEAD, and POST are the most commonly used. Other methods defined in the HTTP specification such
as PUT and DELETE are not supported by most servers.
url
The address and resource name of the information you are requesting. This argument may be either a string containing an absolute URL (the hostname is required),
or a URI::URL object that stores all the information about the URL.
$header
A reference to an HTTP::Headers object.
content
A scalar that specifies the entity body of the request. If omitted, the entity body is empty.
The HTTP::Date module converts date strings from and to machine time. The HTTP::Daemon module can be used to create webserver applications, utilizing the
functionality of the rest of the LWP modules to communicate with clients.
</cite>
Und wenn Du Perl installiert hast, dann tipp mal perldoc lwp ein, dann bekommst du Hilfe zu LWP (Library for WWW access in Perl).
Gruß Frank
P.S. ich schicke Dir das einfach mal per Mail, es sprengt den Rahmen des Forums