473,594 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Write to File question

von
I am writing data from a Javascript to a text file using a Perl script and
it all works pretty well - except ...

This:

"Here is my data"

becomes:

"Here%20is%20my %20data" when it gets to the text file.
Is there a way to replace the "%20" for a normal space as the Perl script
writes it to file??

Thanks. :)
Jul 19 '05 #1
8 6249
von wrote:
I am writing data from a Javascript to a text file using a Perl


Somewhere you are not telling us something because taking your description
literally it doesn't make any sense.
What are you doing?

jue

Jul 19 '05 #2
von
I am running a Javascript that generates a piece of data.

I am then sending this data to a text file via a Perl script.

Somewhere along the way the spaces in-between the data are changed to
"%20" - and I would like to change them back to spaces to make it easier to
read.

:)

"Jürgen Exner" <ju******@hotma il.com> wrote in message
news:qAfQd.1879 8$uc.16755@trnd dc05...
von wrote:
I am writing data from a Javascript to a text file using a Perl


Somewhere you are not telling us something because taking your description
literally it doesn't make any sense.
What are you doing?

jue

Jul 19 '05 #3
[Top-posting fixed, please don't do that]
von wrote:
"Jürgen Exner" <ju******@hotma il.com> wrote in message
news:qAfQd.1879 8$uc.16755@trnd dc05...
von wrote:
I am writing data from a Javascript to a text file using a Perl
Somewhere you are not telling us something because taking your
description literally it doesn't make any sense.
What are you doing?

I am running a Javascript that generates a piece of data.
I am then sending this data to a text file via a Perl script.
Saying the same thing again in the same way doesn't really help
understanding.
Trying to rephrase, please correct me if I missunderstood:
You have a Javascript, that sends data to a Perl script, which in turn
writes the data to a file.

If this is correct then you didn't tell us anything about _HOW_ the data is
transmitted between the JavaScript and the Perl script. And obviously that
is the crucial point.
Somewhere along the way the spaces in-between the data are changed to
"%20" - and I would like to change them back to spaces to make it
easier to read.


But you didn't tell us what the way is.... :-(

jue
Jul 19 '05 #4
von
Okay - let me start over. :)

I have a Javascript that generates a piece of information that I want
written to a file on my server.

I used this in the Javascript to send it to a Perl Script:
_______________ _______________ ___
var i=new Image();

i.src="http://www.mydomain.co m/cgi-bin/write.pl?" + user;

_______________ _______________ ________
Then I use the following Perl script (write.pl) to send the data to my text
file:
_______________ _______________ __
#!/usr/bin/perl

use CGI::Carp qw( fatalsToBrowser );
$isdata= $ENV{QUERY_STRI NG};

# Set $data_file to the location and name of the file in question.
my $data_file = '/usr/home/mydomain/public_html/data1.txt';

open (DATA, "+>>$data_file" ) or die "can't open $data_file $!";
print DATA "$isdata";

{
print "$_\n";
}
close (DATA);
_______________ _______________ ____

My problem is that the data arrives to the text file with '%20' in place of
the spaces.

ie: "This%20is%20th e%20data"

I would like the '%20' converted back to spaces.

I have been playing with 'unescape()' but I can't seem to get it to work
(user error I'm sure).

Any help would be appreciated.

:)

Jul 19 '05 #5
In article <1b************ ********@comcas t.com>, von <vo*@vonvon.com >
wrote:
Okay - let me start over. :)

I have a Javascript that generates a piece of information that I want
written to a file on my server.

I used this in the Javascript to send it to a Perl Script:
_______________ _______________ ___
var i=new Image();

i.src="http://www.mydomain.co m/cgi-bin/write.pl?" + user;

_______________ _______________ ________
Then I use the following Perl script (write.pl) to send the data to my text
file:
_______________ _______________ __
#!/usr/bin/perl

use CGI::Carp qw( fatalsToBrowser );
$isdata= $ENV{QUERY_STRI NG};

# Set $data_file to the location and name of the file in question.
my $data_file = '/usr/home/mydomain/public_html/data1.txt';

open (DATA, "+>>$data_file" ) or die "can't open $data_file $!";
print DATA "$isdata";

{
print "$_\n";
}
close (DATA);
_______________ _______________ ____

My problem is that the data arrives to the text file with '%20' in place of
the spaces.

ie: "This%20is%20th e%20data"

I would like the '%20' converted back to spaces.


$isdata =~ s/%20/ /g

You can also try the query_string() method of the CGI module, but I
can't tell from the docs whether that decodes the URL encoding or not.

FYI: this newsgroup is defunct. Try comp.lang.perl. misc in the future.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 19 '05 #6
von wrote:
Okay - let me start over. :)

I have a Javascript that generates a piece of information that I want
written to a file on my server.

I used this in the Javascript to send it to a Perl Script:
_______________ _______________ ___
var i=new Image();

i.src="http://www.mydomain.co m/cgi-bin/write.pl?" + user;


Sorry, can't help you with that. Never used Perl in a CGI environment.

But I heard of some URI::decode or something similar to that on CPAN.

jue
Jul 19 '05 #7
von
Jim Gibson wrote:

(snip)

FYI: this newsgroup is defunct. Try comp.lang.perl. misc in the future.

Thanks Jim :)
Jul 19 '05 #8

"von" <vo*@vonvon.com > wrote in message
news:1b******** ************@co mcast.com...
Then I use the following Perl script (write.pl) to send the data to my
text file:
_______________ _______________ __
#!/usr/bin/perl

use CGI::Carp qw( fatalsToBrowser );
$isdata= $ENV{QUERY_STRI NG};
open (DATA, "+>>$data_file" ) or die "can't open $data_file $!";
print DATA "$isdata";
My problem is that the data arrives to the text file with '%20' in place
of the spaces.

ie: "This%20is%20th e%20data"


You can do this kind of thing using your own code, but the best way to do it
is to use the functions provided by the Carp module.

Start with
use CGI;

and have a look at the documentation for it - it's a much better way to do
things than to process STDIN "manually", since someone else has already
written the code you need to do the job. Any beginner's tutorial online
that talks about perl and CGI will tell you what to do.

Matt
Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2318
by: lawrence | last post by:
I'm probably missing something obvious, but I'm unable to write a file with this function. I've used my FTP software to set permissions to 777 on all the files in question. I've tried r, r+, w, and w+ as possible ways of opening the files. The first fopen is trying to create a file where none exists. It fails (thought I've set dir permissions to 777 as well). How can I create a file? There error messages print back the full input, so...
3
8580
by: burdeen | last post by:
I can't find any way of writing a unicode, or UTF-8 format text file. Right now i have a Unicode string that i write to the text file and the unicode characters are replaced with ANSI question marks '?'. Please, How do i accomplish this? I've been searching for a solution for weeks... why has nobody even asked this question? shouldn't it be a FAQ?
11
26818
by: Russ | last post by:
My web app writes some binary data to a file at the client site via Response.Write and Response.BinaryWrite. This action is accomplished in response to a button click, with C# code behind as follows: private void SubmitButton_Click (object sender, System.EventArgs e) { // Set up the response to write the print file to the client Response.Clear (); Response.AppendHeader ("Content-Disposition", "filename=WebPrint.prn");
5
2022
by: Arvind P Rangan | last post by:
Hi, i like to read an existing xml file which has a schema defined to it, and then write or add data to the existing xml file using vb.net/c#. May be this Question has been answered earlier. Pls if anyone knows the link or example let me know Thanks ARvind.
5
3652
by: philip | last post by:
Here is some lines of code than I wrote. You can copy/paste theis code as code of form1 in a new project. My problem is this one : I try to write in a file a serie of bytes. BUT some bytes written in file are not the sent bytes. Copy and paste the following lines to observe my problem. What can I do to resolve problem ? Only System.Text.Encoding.ASCII write the same number of bytes, but not the good bytes. Someone can help me. Thanks by...
2
3520
by: key9 | last post by:
Hi all look at the organize tree main.c ------ #include lib_adapter.c main() { foo();
14
5213
by: Frank | last post by:
I see that ImageFormat includes exif. But I can't find out if I've System.Drawing.Image.FromStream or something like it can read and/or write that format.
3
5305
by: golden | last post by:
Hello, I am going to ask a question regarding write and lseek. I will provide code at the end of this, but first some background. I am trying to identify the cause of some latency in writing to disk. My user claims that performance is much slower on SAN than on local disk. The developer provided me a C++ program that performed a write
20
5097
by: cscorley | last post by:
For some reason, I cannot use fopen() on the file in write mode. The file "time" is in the same directory as the .php file, with permissions set to 0766. PHP Version 5.2.5 Apache/2.2.8 code snip in question: $file = "time";
3
2033
by: Ben Keshet | last post by:
I have a probably simple beginner's question - I have a script that I am currently able to print its output. instead, i want to write it into a file - I tried different versions of write() but might have gotten the syntax wrong. the variable I want to write is a line from a file I am reading: "... f = open('receptor.mol2', 'r') line = f.readline()
0
7941
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8246
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8368
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6652
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5404
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3854
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3895
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1205
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.