CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Win32 Programming Help:
running a program from the command line, called via cgi

 



wpearsall
Novice

Jun 29, 2002, 5:17 AM

Post #1 of 4 (4032 views)
running a program from the command line, called via cgi Can't Post

Got a .exe file, in it i need to run from the command line (MS DOS Prompt) like this:

C:/xitami/cgi-bin/mailto/mailto.exe -U admin@mydomain.com -h mydom.com -D $FORM{EMAIL}

how do i make it call the application from a CGI script?


fashimpaur
User

Jul 1, 2002, 7:37 AM

Post #2 of 4 (4027 views)
Re: [wpearsall] running a program from the command line, called via cgi [In reply to] Can't Post

wpearsall,

Not sure, but I don't think you have provided enough information.

I would think the form action tag should be able to be set to mailto.exe, but I
am not sure how you would pass the -U, -h and -D switches and values. These
normally would be passed as parameters to a CGI script in the following manner:


Code
 <form action="mailto.exe&from=admin@mydomain.com&host=mydomain.com" action="POST"> 
Email Address:<input type="text" name="to">
</form>

Then, when the form is sent to the cgi-bin via CGI, the start values would be passed
and the value entered in the email form would be entered. I would not be thrilled
with this, because someone could copy the action tag and possibly use your mailer to
send stuff to the person entering the info. But, logistically, this is how it is done. I
am not familiar with the mailto.exe program so my variable names are definitely in
error. This was just an exercise to show how cgi parameters are passed.

If all else fails, you could do this:


Code
 #!/user/bin/perl 
use strict;
use CGI;my $cgi = new CGI;
my $params = $cgi->Vars();foreach my $key(keys %$params){
$params->{$key} = $cgi->escapeHTML($params->{$key});
}


my $command = qq~mailto.exe -U admin@mydomain.com -u mydomain.com -D $params->{'to'}~;
qx/$command/;print $cgi->header();
print $cgi->start_html(title => 'Done');
print "An email has been sent to you.";
print $cgi->end_html();

Then, change your action tag to be strictly this script, for example, if you named this
script "mailer.cgi":


Code
 <form action="mailer.cgi" method="post"> 
<input type="text" name="to">
</form>

I hope that this answered your question. If not, repost and be more specific about
the issue and what you are trying to do.

Good Luck,
Dennis

$a="c323745335d3221214b364d545".
"a362532582521254c3640504c3729".
"2f493759214b3635554c3040606a0",
print unpack"u*",pack "h*",$a,"\n\n";


wpearsall
Novice

Jul 1, 2002, 9:21 AM

Post #3 of 4 (4023 views)
Re: [fashimpaur] running a program from the command line, called via cgi [In reply to] Can't Post

OK, maybe do need to explain a little more, you know how you bring up MS Dos, and CD to the directory where the .exe file is?

then type "Filename.exe -U address@domain.ext -D address@otherdomain.ext" then hit enter, it then makes the .exe launch, and run, send the email, and then close itself, well i wanna do that from CGI Script,

The program is MailTo from http://xitami.com/addons.htm

Maybe that helps? ne how, instead of interacting with SENDMAIL, or BLAT, *which i'm thinking i may need to switch to -shrug-*, i want it to interact with MailTo

(hope i put it better that time?)

Wayne


fashimpaur
User

Jul 2, 2002, 1:43 PM

Post #4 of 4 (4021 views)
Re: [wpearsall] running a program from the command line, called via cgi [In reply to] Can't Post

wpearsall,

Then, barring any errors in my script in my original post, that would handle an
input from a form with an email input box for the person you are attempting to
send the mail to. Try it out and let me know if you have any problems.

Quote
If all else fails, you could do this: this is the text in a perl script to be saved as mailer.cgi


Code
   #!/user/bin/perl   
use strict;
use CGI;
my $cgi = new CGI;
my $params = $cgi->Vars();foreach my $key(keys %$params){
$params->{$key} = $cgi->escapeHTML($params->{$key});
}


my $command = qq~mailto.exe -U admin@mydomain.com -u mydomain.com -D $params->{'to'}~;
qx/$command/;print $cgi->header();
print $cgi->start_html(title => 'Done');
print "An email has been sent to you.";
print $cgi->end_html();

Then, change your action tag to be strictly this script, for example, if you named this
script "mailer.cgi":


Code
   <form action="mailer.cgi" method="post">   
<input type="text" name="to">
</form>



Good Luck,
Dennis

$a="c323745335d3221214b364d545".
"a362532582521254c3640504c3729".
"2f493759214b3635554c3040606a0",
print unpack"u*",pack "h*",$a,"\n\n";


(This post was edited by fashimpaur on Jul 2, 2002, 1:47 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives