473,472 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

creating log file with content from HTTP post/responce

alexsts2013
6 New Member
Hi,
can someone lend a hand or idea how to create log file in specific location from following:

Expand|Select|Wrap|Line Numbers
  1.  
  2. #!/usr/bin/perl
  3. use LWP::UserAgent;
  4. use File::Slurp;
  5. use warnings;
  6. use strict;
  7.  
  8. my $ua = LWP::UserAgent->new;
  9. $ua->timeout(10);
  10.  
  11. my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
  12. my $current_year = (localtime)[5] + 1900; 
  13. my $current_month = sprintf( "%02d", $month + 1 );
  14. my $current_day = sprintf( "%02d", $dayOfMonth);
  15. my $date = "123" . $current_year . $current_month . $current_day;
  16.  
  17.  
  18. my $url = "http://somesite.com/cgi-bin/upload.cgi";
  19.  
  20. my $file = "D:/inputfile" . $current_year .$current_month . $current_day . ".xml";
  21. my %args;
  22. my $field_name = "filename";
  23. my $buf ;
  24. my $buf_ref = $args{'buf'} || \$buf ;
  25.  
  26.  
  27. my $value = read_file( $file , binmode => ':raw' , scalar_ref => 1 );
  28.  
  29. my $response = $ua->post( $url,
  30.             Content_Type => 'form-data',
  31.             Content => [ $field_name => ["$file"] ]
  32.             );
  33. print $response->content;
  34.  
  35.  
  36.  
Basically I need to place content of "$response" into log file and write it in specific location.
Unfortunately all attempt to read it failing. I could read it in C#, but since cgi does not work well with C# I had to use Perl and in Perl I am a newbie...
Any help will be appreciated.
Thanks.
Jun 10 '13 #1
1 1646
numberwhun
3,509 Recognized Expert Moderator Specialist
A log file is simply a file. You can read about handling files here: http://www.perlfect.com/articles/perlfile.shtml

You could also employ a module like Log::Simplest.

How you handle logs is completely up to you, but you'll have to ensure that failures are caught and necessary items happen, otherwise a log entry is made.

Regards,

Jeff
Jul 2 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Gary Petersen | last post by:
For the benefit of others, I want to show how to do an HTTP POST request using fsockopen(). I banged my head against a wall for two days trying to figure this out. I even went to http://php.net/...
5
by: designsimply | last post by:
I am trying to http post some xml to to a remote server using php. When I try to submit xml using PEAR's HTTP_Client::post() to the remote server, I get back the following "Invalid Document Format"...
13
by: RHPT | last post by:
I am wanting to capture the XML posted by an InfoPath form with .NET, but I cannot figure out how to capture the XML stream sent back by the InfoPath form. With Classic ASP, I could just create an...
1
by: Jason Ho | last post by:
Hi, I would like to send a jpg file to a HTTP server by POST request. But I am not using a browser to do this, I use a Windows Form instead. I know how to send typical request by POST with code...
0
by: WIWA | last post by:
Hi, I want to login to a password protected website and fetch the content of the page behind. I have based my code on http://weblogs.asp.net/jdennany/archive/2005/04/23/403971.aspx. When I use...
3
by: Patrick Fogarty | last post by:
I am programming what is to be a web service client that will use an HTTP-POST to request and retrieve data. The remote server (written in java for what it's worth) requires basic authentication...
3
by: JansenH | last post by:
We have implemented a 'HTTP Post' client in C# that posts Xml documents to a webserver. This is working fine if the post rate is one post for every 20 seconds. But if the post rate is increased to...
6
by: majik92 | last post by:
Hello, I'm in the process of rewriting a program I wrote in LUA to VB.NET. So, I am still learning the language (VB). I just have a question... I have a windows form called "mainPage". I want...
2
by: MDANH2002 | last post by:
Hi From VB.NET I want to simulate the POST request of the following HTML form <html> <title>HTTP Post Testing</title> <body> <form action=http://www.example.com/postdata ...
7
by: John Dow | last post by:
I am trying to receive/send xml files with predefined schema from/to another server using http post, and a success message back to the sender Would someone give me a start point where I can start...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.