Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Data Between One Script to Another

Status
Not open for further replies.

gilep

Technical User
Jul 30, 2008
2
Hello,
I am trying to set up a site to design calendars using my users' pictures. In order to do that I have built a form that users can attach files to it and send it to my server (using form2mail CGI script attached below). It works well but only for small files. For large files (I need to upload up to 13 files, each can be up to 5 Mb) it crashes after an hour and no files are saved. My host replied to me that there is a timeout on the server that they do not wish to increase.
Since the script works well for a single large file, my idea is to call it several times, and each time asks it to handle and upload only a single file. However, I want my users to fill the form and insert the names of the files they want to upload only once. So after the script is called the first time by the form, I need a way to call another script again (automatically, without user's intervention) and to pass the file names collected by teh first script to it. Since the script ends with calling an html thank you page, I though of using this page to call the second script using
<meta HTTP-EQUIV="REFRESH" content="0; url=http://gilep.netfirms.com/cgi-bin/gilepf2mcalendar.pl">
This command does eth job but again I have no idea how to pass the information from one script to the other.
The file names are stored in my @file_upload_fields.
BTW, I have no programming expertise what so ever.
Thanks for any help related to these issues.
Thanks,
Gil
 
How I do it is using a system call ... you can use something like this.
Code:
foreach (@file_upload_fields) {
    system "gilepf2mcalendar.pl $_";
}
Then in your other script catch them by:
Code:
my $catch = <ARGV>;

Something like that.
Let me know if this helps.
 
However, I want my users to fill the form and insert the names of the files they want to upload only once. So after the script is called the first time by the form, I need a way to call another script again (automatically, without user's intervention) and to pass the file names collected by teh first script to it.

Can't do it. Could you image how easy it would be to steal files from peoples computers if you could do something like that?

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
i think the problem with the "system" function is that -- to my knowledge -- it is a blocking one. meaning: the system call will return only after the command invoked by it has terminated. i don't know, but i would expect, that the script invoking the "system" function would still be killed because it runs too long and the invoked process would die with it.
i would suggest a solution using fork:
Code:
for (my $i=0; $i<=$#files; $i++) {
  if (fork() == 0) {
    # child-labour :D
  }
}
this would spawn multiple processes. you could also just spawn a single new process after one picture was uploaded. maybe that would be somewhat like
Code:
for (my $i=0; $i<=$#files; $i++) {
  if (fork() == 0) {
    # child-labour :D
  } else { 
    exit(0);
  }
}
if neccessary (and available in perl, i don't know. only used them in C before) you can take a look at semaphores to coordinate processes. you could use them for example to keep a count (managed by the operating system) of the current number of worker processes, so the last one out can output a message to the user agent.

hope this helps,
cheers
michael
 
Forget it, you can't do it. MOst (all?) web browsers ignore any attempt to pre-fill the value of an <input type=file> form field for good and obvious reasons. It does not matter how you try and do it in this situation, it can't be done, at least not any any way that would be considered practicle and even ethical. And if there is a way to do it I don't know about it but it would be considered hacking since it would require the web browser to do something it is not supposed to do.

I know back in the day Opera would use a pre-filled value but it also required that the user click on a dialog box to confirm the action since it is inherently insecure.

Give up on this idea.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
seems sensible :) the goal for my suggestion was primarily to circumvent the timeout of the script. (btw, how does the server kill the script? maybe installing some signal handlers will do the trick *g*). if you pass all <input type=file> values at once and the perl script takes care of evrything else, security wouldn't be breached. the browser should never know, that it implicitly invoked multiple scripts.
i'm not sure if i understood this correctly, but the security-issue only arises, if you use the REFRESH-thing gilep mentioned in his post, right? if one finds a way to circumvent the timeout of the script, the browser wouldn't have to pre-fill any form fields.
or am i just missing something?
cheers
michael
 
If you don't have much of a programming background, your hurten for what you want to do.

In complement to KevenADC's security concerns, the result of such a coding capacity would result in a bucket load of new Trojan viruses and spy ware.

One thing you can try though is save the user's file names in a cookie, open a second browser application (a`la java), have the second window loop over the file names sending them one at a time. From here you can present your "Thank you" screen and let the user get back to whatever it is they're doing (or am I too out of pace with your initial problem?)
 
Pinkey,

are you sure that is even possible to do using javascript?

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Nope - sorry for the error on my part. I was forgetting the server/client side of things. Client side Javascript doesn't allow it.

But there may be one last, albeit extreme, possibility: gilep, have your users modify their PCs to be server side hosts.
 
Servers monitor usage by how much CPU resources any particular application uses, how much memory it uses, how much time it takes to run, etc. If you want your account deleted and any payments you made forfieted, then try and abuse the server. I don't recommend it.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
First, thanks for all the ideas and tries to help me out with this although some were well beyond my limited knowledge.
Let me try and calrify the problem. It starts when the user fills a form and selects 13 pictures located on his PC to be uploaded to my web site. As long as the files are not more than a few hundereds KB, everything works fine. When each of the files is 3 MB for example it crashes and no files are saved at all (also quite strange). When smaller number of large files is uploaded it works well. The script restriction for the file size (for each file) is set to 6 MB so this is not the issue. The reply I got from my server host was that there is a timeout that I probably exceed and this is why it crashes. They told me that the timeout is 5 minutes which is also quite strange as the script works fine and uploads for 20 and 30 minutes and when it crashes it is after an hour or more.
Since the script handles well a single large file, I thought of calling it several times but without bothering the user to enter each file name separately and do it "behind the scenes".
People suggested me to look for a solution based on PHP but I found out that I need to configure some parameters that my host does not allow me to do. Others suggested to look for a web based FTP client solution but that I couldn't find something that would be simple enough that the user will only have to select the files and push the upload button and it also requires to have a certain version of JAVA installed.
This is why I came up with this question.
Any other other ideas on how to solvesuch an issue woudl be mostly welcome.

Thanks,
Gil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top