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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command line 2

Status
Not open for further replies.

curvv

IS-IT--Management
Jan 11, 2001
103
ZA
Hi,

I'm using win2k and would like to know how I can access command line commands from php.

I want to use this to send mail using blat. blat is in the system path.

thanx ######## CtN ########
 
Have you tried the popen() function?

$fp = popen("Blate.exe -t......","w+");

etc.

or even

shell_exec("Blat.exe -t........");

etc.

Chad. ICQ: 54380631
online.dll
 
Hi,

I'm going to have to go read about that.
I'll come back if I have any problems.

thanx ######## CtN ########
 
Hi,

Everything works fine. Thank you.

Question:

How can I return Blat-output to the screen after sending the mail?

Thanx ######## CtN ########
 
string exec ($command, $return_data,$pass_fail);

$return_data will give you the return data in an array and $pass_fail will give you either TRUE or FALSE.

chad. ICQ: 54380631
online.dll
 
Hi,

I get a parse error when doing this


??

######## CtN ########
 
post the code here so I can take a look at it.

chad. ICQ: 54380631
online.dll
 
Hi,

This is just a short piece of code that I tested to use blat. How do I get the uotput from blat displayed after the thank you message?

<?
$out=&quot;Blat - -body \&quot;$user<br>$body\&quot; -t \&quot;lhcintranet@liberty.co.za\&quot; -s \&quot;BLAT!! TEST TEST\&quot; -i \&quot;$from\&quot; -html &quot;;
shell_exec(&quot;$out&quot;);
echo &quot;Mail successfully sent. Thank you $user<br><br>&quot;;
?> ######## CtN ########
 
Here you go! Sorry it took so long...we had a major debug today at work.

Chad.

<?
$out=&quot;blat -body \&quot;$user<br>$body\&quot; -t \&quot;lhcintranet@liberty.co.za\&quot; -s \&quot;BLAT!! TEST TEST\&quot; -i \&quot;$from\&quot; -html&quot;;
@exec($out, $return_data,&$pass_fail);

if(!$pass_fail) {
echo &quot;Mail successfully sent. Thank you $user<br><br>\n&quot;;

for($a=0;$a<count($return_data);$a++) {
echo $return_data[$a].&quot;<br>\n&quot;;
}
}
else {
echo &quot;Couldn't send email!<br><br>\n&quot;;
}
?>
ICQ: 54380631
online.dll
 
Hi,

thanx alot. appreciate it!

Chris ######## CtN ########
 
Hi,

I'm trying to attach a file with the -attach switch, but get this output from blat.

Attached binary file: C:\\Documents and Settings\\czb0204\\Desktop\\lhcquotes.exe
File not found: C:\\Documents and Settings\\czb0204\\Desktop\\lhcquotes.exe

i've tried ereg_replace to get rid of the slashes. If the slashes is the problem, how do i get rid of the little not-so-verticals ??

######## CtN ########
 
Well, I am not a good one to answer that one.

I am a Linux guy, but from my experience, try to hard code the location of the file and try to user / instead of \ OR do a stripslashes:

$location = stripslashes('C:\Documents and Settings\czb0204\Desktop\lhcquotes.exe');

Try that. I hope it works or you get it solved.

Chad. ICQ: 54380631
online.dll
 
Hi,

Got it right!

I first used $file=stripslashes($file); and the slashes then went through correctly as C:\docu~1\bla.exe. But then got the error that it could not find the temporary file created by php - D:pHPUploadphp51.tmp (notice no slashes). I then removed the $file=stripslashes($file); and everything worked fine. The problem before was the enctype=&quot;multipart/form-data&quot;. The only problem I have now is that the attached file is now called php51.tmp and not bla.exe.

thanx ######## CtN ########
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top