Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Can I Launch A Local .bat File With PHP?


I need to write small web app that can launch a few .bat files from a local machine.
Is this possible with PHP, or would javascript be a better option? All i need to do is select the file (some HTML) then have a button to execute.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Posting Local File Info To A Php File!
I have a script that I run locally and im trying to get the info to post to a php file so that I can view it in a browser. What I need to know is how to set up the receiving php to post it to the .html . Now I thought it went along the line of creating the php file and putting it on the root of the server then running the local script against a that php info file and it would dump the info to a browser but it wont work like that (I'm guessing cause it's a local script and not on the web)

I know this line is sending it to the .php in that directory but I don't know how to set up the receiving php I guess is my problem.

gosub phpsend www.xxxxxxxxxxxxx.com /xxxxx/xxxxxxxxx.php %sendstring

I guess what I need to know is whats the best way to post the received data to a browser after the script runs. Or to set up the receiving php file as for outputting it I can create the page I just need to know how to receive it .

Writing To A Local File
We have a PHP/MySQL database application. A user would like to be able
to run a routine to read selected data from the database and export a
flat file to their local C: drive. After reviewing the documentation
and posts, it is not clear how to do this, or even if it is allowed by
the browser. If someone could point us in the right direction, we
would greatly appreciate it.

The application is hosted on a Linux server.
The users are required to use Internet Explorer running on Windows 2000
or XP (we also use VBScript).

Check If A File Is Local
Is There A Function Or Method Which Can Check Wether A File Is Local.

Reading Local File Not On Server
I am trying to parse a file which is located on the users local drive and then take this data and put it into the mySQL DB. However, I get errors when I pass in a file path such as C:Documents and SettingsAdministratorDesktopfooSLInfo.txt.

Read File On Local Drive
lets assume that the sysadmin granted to read those files, what php functions needed? can u give me ur ideas how to do it?

How To Process A Local File Rather Than Just Read It
I can read a local file with

fopen("myFile.php");

However this gives me the source of the file (i.e. php code). I want
to get the results of the file after it has been evaluated (i.e. HTML).

The obvious way of doing this is

include 'myfile.php'

However, I want to process the evaluated result. For example:

echo htmlentities( include 'myfile.php' );

This doesn't work because the result of the include statement is true
or false rather than a string.

I'm sure this is very simple, but I'm just learning.

Launch Recording From PHP
I'm working on a small web-script that would allow me to remotely setup
recordings to my tv-tuner (on my linux box). The idea is simple, but I'm
unsure how to accomplish it.

The idea: Using PHP generated www-page user could set mencoder to start
recording at some specified time. The command is put to the crontab
using linux "at" command.

Problem is that I don't think it is an good idea to grant www-data user
(that runs apache/php process) to tinker with audio and video hardware.
Even worse idea is to grant www-user rights to use "at" command.

I use mysql database to store some recording information and thus I
could use mysql TRIGGER-functionality to put the recording command to
crontab, however at that case I should give mysql user video and audio
priviledges. Again - not so good.

Can anybody give an good advice how to do this wihtout dangering system
security?

Launch New URL In New Window
So basically what I'm trying to do is this:

If ($var == 1)
{
Launch http://www.google.com in new window;
}
Else
{
Launch http://www.yahoo.com in new window;
}

What would be the proper coding for this?

I know how to do the rest, just don't know what the command for launching a new webpage would be.

Writing A Local XML File From A Parsed URL? Similar To RSS
I am trying to pull the XML data from the following stream:
http://......and write it to a local file.

Actually, what I would like to do is take the above stream and display
it into a website... much like displaying RSS feeds on a webpage.

I looked at javascript, but someone there pointed me to the PHP group.
I may not have worded the subject correctly.

Copy Large XML Output To A Local File
I have a URL that when called generate a very heavy XML Feed like:

www.domain.com/generateXML.php?id=products

when i call this URL in the browser i can see a very long XML file generated containing different information..i want to copy this all output to a local file on my server so that i can use that file's info for different tasks on my site...PHP Code:

Selecting A File In Our Webspace From Our Local System
How to read a file which is in our webspace from localsystem in php.

Include Text File From Local Computer
how do i "include(file.txt); if i have it stored on my computer for security reasons or do i have to upload it to my domain.

MSWord Launch From A Link
I am storing uploaded Word Documents in a directory and I want to be able to click on a link on a web-page, and view one of them. But when I click on the link, my browser (IE5) attempts to read it and I get a load of nonsense on the screen. ( Although I can just make out bits of the document!) This is my code -

1. After uploading, I have this:

if (!copy($cv, "cvs/cv".$cid) ) {
echo("Problems encountered receiving your CV. However your application will still be processed.");}

PHP-generated Link To Local File Doesn't Work When Clicked On. Why?
I'm running an Apache server on my own computer (Windows XP Pro).

I wrote a simple PHP script (called test3.php) that I'm running by
putting the following URL in the address bar of the browser (Firefox)
....

http://localhost/test3.php

The script generates the following link using the echo statement ...

<a href="file:///C:/pictures/xyz.jpg"> Picture </a>

("C:/pictures/xyz.jpg", as you can guess by now, is an image file on
my harddrive, but it's not in the document root).

When I clicked on the link, nothing happened. However, if I
RIGHT-click on it and select "Copy link location" (which copies the
URL to the clipboard) and then paste the URL into the address bar of
the browser, the picture then displays correctly.

Why did it not work when I clicked on the link the first time, but it
only worked when I pasted the link to the address bar?

Is there some special notation/syntax that I need to use to get this
to work properly?

How To Populate HTML Table From Local Text File.
I am looking for a way to populate an HTML table from an external
local text file which looks like this:

DATE/TIME LAT. LON. DEPTH. ML.
-------------------- ---------- ---------- ------- -------
21/03/2005-04:06:03 XX,XX XX,XX 171 3,42
21/03/2005-12:23:53 XX,XX XX,XX 500 5,4
21/03/2005-12:43:10 XX,XX XX,XX 553 5,38
21/03/2005-18:47:51 XX,XX XX,XX 162 3,91
21/03/2005-19:29:49 XX,XX XX,XX 500 3,51
21/03/2005-20:04:51 XX,XX X,X 75 3,72

The file could have more rows (DATA) that I show here. The file is
provided to me on a daily basis and I have to update a web page daily
with the contents of the file.

I considered using JavaScript embedded in the HTML page but I am a
newbie on what scripting for the web it refers.

How can I populate the HTML table with this text file which changes
everyday.

Also, is it possible to use php client-side only, without a server?

File Form - Keep Local Path Info On Reload
Is there a way to retain the local path info for a file form when the page reloads?

Launch A Background Task From A PHP Script?
For example, when a user posts on my message board, it may fire many
e-mail notifications to other users, and other tasks. I want the
posting confirmation page to end displaying quickly, without waiting
for those notifications or other tasks to complete.

So basically what I want is to launch 'background.php' from 'main.php',
with the user seeing only the output of - and waiting only for the end
of - 'main.php'. Without the need to wait for the end of the possibly
long 'background.php', like if I had simply included it in 'main.php'.

According to the PHP Manual, the function register_shutdown_function()
was the solution "in PHP 4.0.6 and earlier under Apache", but "since
PHP 4.1 the shutdown functions are called as the part of the request"
so that PHP waits until the shutdown functions are completed before
closing the connection to the user.

E.g. in PHP 4.1+ this

<?php
function background () {
echo 'Starting background task... '
// Do something long that I don't want the user to see or wait for
sleep(5);
echo 'End of background task. '
}

echo 'Starting main script... '
register_shutdown_function('background');
echo 'End of main script. '
?>

will output:

Starting main script... End of main script. Starting background task...
End of background task.

I want a way to output only:

Starting main script... End of main script.

Problem To Launch A Program With System()
I wrote a JAVA program which uses the JAVA API JDOM 1.0 (of this site
www.jdom.org)
I put the archive jdom.jar in the directory /usr/share/java/jdom.jar
and I added this path in the CLASSPATH variable.
The program runs normally when I launch it in a unix shell.

Now, I want to launch this JAVA program in a PHP program with system()
function for example. I have an Apache server with PHP 4 who runs. The
variable safe_mode of PHP is at off. So, the program PHP can launch
executable program.

But, It doesn't because of CLASSPATH problem I think. So, to understand
where is the problem I recuced my programs and this is the 2 programs :

- program JAVA :

import java.io.*;
import org.jdom.*;
import org.jdom.input.*;

class TestSAX{

TestSAX()
{

}

void instanciateSAXBuilder()
{
//On crée une instance de SAXBuilder
try{
SAXBuilder sxb = new SAXBuilder();

System.out.println("Constructeur de SAX");

}catch(Throwable e){

e.printStackTrace();
}
}

}



Copying File From Hosted Remote Sever To Local Machine
I am trying to use php to automate the copying of a file from my remotely
hosted directory to my computer. I have put together the following but it
will only do the copying from one directory to another on the remote server.
Reading the postings on these functions they suggest that it can be done but
it appears to be the case if your are hosting your site on the same machine
you want to copy the files to. Does anyone know if there are functions in
php to do the transfer from remote server to my machine or if the code below
will acheive this with modification?

<?php
$ftp_server = "xxxxxxxx";
$ftp_user = "xxxxxxx";
$ftp_pass = "xxxxxx";
$local_file = 'myfile.txt'
$server_file = 'myfile.txt'

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to
$ftp_server");

$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
die("FTP connection has failed !");
}

// try to change the directory to myfilesdirectory
if (ftp_chdir($conn_id, "myfilesdirectory")) {
echo "Current directory is now: " . ftp_pwd($conn_id) . "";
} else {
echo "Couldn't change directory";
}

if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file";
} else {
echo "There was a problem";
}

// close the connection
ftp_close($conn_id);

NovelSpace Media, LLC Announces The Launch Of Their New Online Bookstore And Web Portal Devoted To Developers And Programmers.
NovelSpace Media, LLC has announced the launch of its new online
bookstore, NovelSpace.com. Located at http://www.novelspace.com, it
features a wide and varied selection of books for computer aficionados,
developers, software engineers, and programmers. In addition to low
prices and shipping fees, NovelSpace.com boasts an easily navigated
interface along with quick checkout and simple account management.
Proceeds from each purchase are donated in support of various open
source projects.

NovelSpace Media is also inaugurating Developer Haven, the first in a
series of web portals to be developed by the company. Designed as an
online resource for programmers and software developers, Developer
Haven features a section devoted to industry news and a directory of
links to websites with code samples, tutorials, components, and
software packages. Users can also test-drive a beta version of DH
Search, an internet search engine tasked exclusively to researching
material related to programming and software development. Developer
Haven can be accessed from NovelSpace.com, or on its own at
http://developerhaven.novelspace.com.

About NovelSpace Media, LLC

NovelSpace Media is a development firm currently specializing in
e-commerce and portal websites. The driving goal of the company is to
offer customers easy access to books and resources at competitive
prices, as well as building thriving online communities around rich
content offered through topic specific web-portals.

LOAD DATA LOCAL INFILE - Workaround For Local-infile=0
I'm using a PHP script for updating my database which relies on the "LOAD
DATA LOCAL INFILE" command. As my provider recently updated the
MySQL-database, he changed the "local-infile" setting to zero, i.e. my
update-script doesn't work anymore (=> "The used command is not allowed with
this MySQL version").

Is there a work-around to fix this problem? I though about the mysql_options
command, but to frankly speaking, I have no clue how to use it and couldn't
figure out how to properly use it even after reading the manual ... anyone
who could help?

Launch New Page And Refresh Exisiting Page
I know about not being able to change header info after output to the browser but what are the workarounds if any?

I have a basic form where a user logs in - the details they submit are verified in supportlogin.php and then if successful I launch another browser window with Javascript but the window in that they logged in at remains on supportlogin.php and is blank... How can I launch the new window and send the first window back to the login page? PHP Code:

Local Value Safe_mode
In my phpinfo, in PHP core i see "Local Value" and "Master Value"

if i change my php.ini file than only master value changes, where do i change the "Loval Value" . I run Apache/2.0.48 on Linux/SuSE

Add Handler ? #!/usr/local/bin/php
I have a web page like this

#!/usr/local/bin/php
<?
echo "hello";
?>

It always shows the first line as text output. Does anyone know how to
let web server or intepreter ignor this line.

I try to add the following line in the httpd.conf
AddHandler cgi-script .php

And make the file executable. It shows " internal server error".
Since this package has around 40 or 50 pages. I do not want to get
into each file and comment it out. Any idea about this?

Local Host
when i am trying to connect a database with this:

mysql_connect (localhost, username, password);

how do i find my local host?

Local Mail
i am running a home server but i can't get mail() to work. what will i do if i have no mail server? im using apache/linux/sendmail.

Local Fsockopen()
I am tring to develop a site that conects via sockets. I am doing the development on a localhost Apache server here's a small code example:-

<?php
$host="127.0.0.1";
$socket=fsockopen($host,80,$errno,$errstr,50);
if(!$socket){echo "NO CONNECTION".$errno.$strerror;}
else
{ fputs ($socket, "GET/apache/htdocs/phpinfo.php HTTP/1.1");
$info=''
while (!feof($socket)) {
$info.=fgets($socket,1024);}
fclose ($socket);
echo $info;

I'm having a problem with the fputs() line. After the GET/ sataement I am trying to direct he socket to a file, so I will be able to read/write but the fputs() doesn't seem to accept any path I put into it. The socket works ok because If I leave out the path I am sent o the apache intro page on my localhost.

Local Variables
I am running a virtually hosted domain on a server that I have root access on also. I rented the server, but the hosting company supply no information on the setup. I'm forced into using their control panel to add domains.

Running a phpinfo() on a virtual domain I have found that although I have set safe_mode to off in the php.ini file something is setting the local value for safe_mode to On.

There are no .htaccess files in the heirachy of folders to the virtual domain. I've checked the <virtual hosting> directives in the httpd.conf and I cant see anything there that might be doinng this.

PHP On Local Machine
Back in 2004 I installed PHP, Apache and MySQL on my local machine to do some testing.

I have not used it since.

I just tried to browse one of my .php test files in IE and it opened up in Dreamweaver!

Everything seems to be in place where I left it, I restarted Apache just in case - but no joy. Is there something simple that I have forgotten to do? - something I should have started up? - or something I can check?

I would like to avoid reinstalling the software if possible as I recall having a few "teething problems."

PHP In Local Development
i got this error:
Fatal error: Failed opening required 'mainfile.php' (include_path='c:php4pear') in d:PHPWEBmyPortalmodulesSearchindex.php on line 19

im doing a local development for testing my php mysql codes. in my little knowledge, i think the error is in the configuration of the php but i don't know exactly how to fix this.

Regex - Matching Local IPs
I'm just trying to get PHP to sniff out local users using preg_match; can anyone spot my error?

preg_match("/(192.168.(0-9){1,3}.(0-9){1,3})¦(10.(0-9){1,3}.(0-9){1,3}. (0-9){1,3})¦(172.(16-31).(0-9){1,3}.(0-9){1,3})/",$_SERVER['REMOTE_ADDR'])

Local/global Variables
I've problems including global variables in my functions. for instance, how do I extract $REMOTE_ADDR, or a session variable, inside a function ?

Local Error Log Is Not Working
I tried to define a local error log for one instance of my webserver, but
PHP seems to ignore it...

As a master value, in php.ini, there is:

error_log = /usr/local/php/log/php.log

As a local value, in obj.conf (SunONE 6.1 webserver):

Service fn="php4_execute" type="magnus-internal/x-httpd-php"
error_log="/www/site/php.log"

But from phpinfo(), I get: .....

Displaying Local Time
How do you display a users local time. I have looked through some help files and they seem to all seem to be showing me how to use the time in conjuction with something else.

Parse PHP On Local Computer
Running Windows XP (Home) and would like to be able to parse PHP locally without having to upload files to my host server and view them there. I know I can install PHP on my PC, but what is the simplest way to set it up as a local server, preferably without needing to install Apache as well?

Configure Open_basedir Local Value?
I'm trying to turn off open_basedir, and according to php.info, I've
managed to do that in the master value column, by editing the php.ini
file.

But it's still on as local value for several domains, and I don't know
where turn it off.

LAMP On A Local Network
I'm new to all this and I am trying to set up a web sever over a local
network. I currently have two boxes attached via a switch. Box 1 is
configured with windowsXP and the other with Fedora3.

The linux box has Apache installed and appears to be running ok. When I use
IE to access the site I get the response : "Page cannot be displayed" or
"The web page you requested is not available offline" depending what is
entered in the address control.

On the Linux box, if I use the command netstat -atn, this shows a host
192.168.123.10 listening on port 80

In the terminal window on the XP box, (192.168.123.12) when I ping
192.168.13.10 I get a successful response. If I telnet 192.168.123.10 80 I
get "could not open connection to the host on port 80:connect failed"

Does anybody have any suggestions /commands that will help me resolve this.

Also does anyone have a link to a good article recommending a development
set-up that includes the physical configuration as well as development tools
for a first timer.

Export Local DB To Server DB
can anybody refer me to a tool so that i can upload data from my local
mysql DB to server DB without phpmyadmin. I have FTP and other access
to server. my DB is like 100 MB.

CGI Variables: /usr/local/bin/php Test.php --x=hello --y=123
My question is the following:
I'm calling a PHP script as CGI over a shell a.e:
/usr/local/bin/php test.php --x=hello --y=123

How is it possible to access the variables x and y in the script.

is there a special array where these variables are stored?
I tried $_ENV and $_GET but it didn't work...

PHP Copy To Local Machine?
I am building a small page to copy files from our server(s) to our users
local machines. It's very simple...
(below, "f" is a mapped network drive)

<?php

$source_file = 'f:somefile.whatever'
$destination_path = (I want to move it to the USERS
C:somedirectorysomefile);

copy($source_file, $destination_path);

?>

Local IMAP Server
I've installed EasyPHP on my Windows machine, which does the job really
fine. Apache, PHP and MySQL easy going.

What are the possibilities for installing a local IMAP and POP server for
the same test/develop purposes?

Slow Down Local Transfer?
I am trying to test a loading bar, but I am running it off my local apache server, which means there isn't any real load time. Is there some way to lock my transfer rate at like 10kbs or something?

Converting UTC To Local Time
My PHP connects with a postgresql database and fetches the last login information of type "timestamp with time zone".

The database returns this value: 2007-08-06 19:05:14.551719-06, but the actual time I have right now is 9:05:14 PM.  I assume the time given by the database is in UTC.  Now, how do I convert this to respect the local time of the user seeing this?

For example, I am located in eastern time zone and  I should be seeing 9:07:14 PM, but someone in central time zone should be seeing 8:05:14 PM.  Is there a PHP code that can convert this time into the local time of the current user viewing the time depending on his geographical location?

Accessing Mail On Local Machine
This is probbly not a php question but here goes:
I recently installed cyrus-imapd.
The imap server is up and running, I am able to login but it says that I have no mail but if i use pine I am able to see all my messages.

Upload To Local Server Problem
Can anyone see where i am going wrong? I'm testing an upload facility. Here's the code for displaying the upload form:

Https Support In My Local Invironment
I need https support in my winxp environment.Is any package ( like wamp, xamp)  which have apache 2.2 with SSL.If any extra configuration is needed for that, please mention that. What will be the way of session management in http and https in a same domain?

Display Country Local Time Through Php
I want to display local time after user select his timezone. I am having trouble doing it. Have you got ideas of how to approach for a solution to this.

Always Local Time & Date Format?
Is there a script available that would re-format a time & date always
according to the users' setting?

Some setting that would be read by the language set in the browser or from
the IP?

Readdir From Local Hard Disk
I have written a script to upload images from a clients hard disk to our server, which works fine.

I would like to display all images on a direcvtory so that I can upload an image based upon the thumbnail display. I am having trouble trying to ger a dir listing the clients c: drive?

$fd = opendir("$ImageDir");
while($entry = readdir($fd)) {
$dis = substr($entry,0,2);
if ($dis!= "10"){
if(eregi(".(jpg¦gif¦png)$",$entry)) {

echo "<a href=$PHP_SELF?pic=/images/$entry>/images/$entry</a>";
echo "<a href="/images/$entry">";
echo "<img src="/images/$entry" align=middle
border=0 height=80 width=100>";
echo " $entry</img></a><br>";
}
Where $ImageDIr could be c:/apache/htdocs/images

Can anybody please help?


Copyright © 2005-08 www.BigResource.com, All rights reserved