473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Running a system command from php

Helo, my first post here....

I am trying to run an agent application that converts and imports two
tables from MS Access into mySql.
(Intelligent Converters - Access2mySql)
I have run similar scripts to do mysql dumps using the system function.
Not sure if the paths included in the parameters are correct:

<?php
function import_data() {
$sourceFile = "C:\Program Files\Intelligent converters\myAccessDB.mdb";
$tableFile = "C:\Program Files\Intelligent Converters\whichTables.txt";
system("/Program Files/Intelligent Converters/A2SAGENT.EXE
--dest=st_staff --src=$sourceFile --tab_file=$tableFile --mode=1");
}
import_data();
?>

This syntax works fine in command line prompt, but somehow it is not
working when called from php. I have tried two versionn of this (one
using user/pass - not shown) and the one above.

Any pointers on running this, and getting results.

Cheers,
John

Sep 9 '05 #1
6 1801
jsw_nz wrote:
Helo, my first post here....

I am trying to run an agent application that converts and imports two
tables from MS Access into mySql.
(Intelligent Converters - Access2mySql)
I have run similar scripts to do mysql dumps using the system function.
Not sure if the paths included in the parameters are correct:

<?php
function import_data() {
$sourceFile = "C:\Program Files\Intelligent converters\myAccessDB.mdb";
$tableFile = "C:\Program Files\Intelligent Converters\whichTables.txt";
system("/Program Files/Intelligent Converters/A2SAGENT.EXE
--dest=st_staff --src=$sourceFile --tab_file=$tableFile --mode=1");
}
import_data();
?>

This syntax works fine in command line prompt, but somehow it is not
working when called from php. I have tried two versionn of this (one
using user/pass - not shown) and the one above.

Any pointers on running this, and getting results.

Cheers,
John


Hi John,

It might have something to do with user-rights, because you execute the
command as the webserver user when you call the script from a webbrowser.
Try to debug it by passing in the second optional parameter to the
system command, which is a reference variable to which the system
command will write the output of the command.

I.e.

system("/Program Files/Intelligent Converters/A2SAGENT.EXE
--dest=st_staff --src=$sourceFile --tab_file=$tableFile --mode=1",
$strOutput);
var_dump($strOutput);

Peter.
--
http://www.phpforums.nl
Sep 9 '05 #2
On Thu, 08 Sep 2005 21:25:23 -0700, jsw_nz wrote:
Helo, my first post here....

I am trying to run an agent application that converts and imports two
tables from MS Access into mySql.
(Intelligent Converters - Access2mySql)
I have run similar scripts to do mysql dumps using the system function.
Not sure if the paths included in the parameters are correct:

<?php
function import_data() {
$sourceFile = "C:\Program Files\Intelligent converters\myAccessDB.mdb";
$tableFile = "C:\Program Files\Intelligent Converters\whichTables.txt";
system("/Program Files/Intelligent Converters/A2SAGENT.EXE
--dest=st_staff --src=$sourceFile --tab_file=$tableFile --mode=1");
}
import_data();
?>

This syntax works fine in command line prompt, but somehow it is not
working when called from php. I have tried two versionn of this (one
using user/pass - not shown) and the one above.

Any pointers on running this, and getting results.

Cheers,
John


I see two possible causes for errors here:

1) to call the program you do not use a drive letter, are you sure the
program is executed?

2) space in path name. Try escaping the spaces in the path names. Space
might be handled differently from a script than from command line.

Paul
Sep 9 '05 #3
Hi Peter,

I condensed the string (just to simplify things), but still it does not
seem to work inside php/system command. I tested in standalone command
prompt....so the expression is correct. One thing as far as this script
is concerned is that the -dest=st_staff utilizes a mysql odbc DSN. I am
wondering if that is throwing it. As far as I know the agent
application requires this in order to function.

A2SAGENT.EXE --dest=st_staff --src=C:\ST_2005.mdb
--tab_file=C:\whichTables.txt --mode=1

The dump_var returns int(1) but the import is not occurring. Thanks for
your help.

Sep 9 '05 #4
Hi John,

So, when you run the AS2Agent.exe command manually from the commandline,
does it output anything?
If yes, then the return value of the system command will hold the last
line of the output of the AS2Agent.exe command. So you could try storing
that like:

$strLastLine = system("/Program Files/Intelligent Converters/A2SAGENT.EXE
--dest=st_staff --src=$sourceFile --tab_file=$tableFile --mode=1",
$strOutput);
var_dump($strOutput);
var_dump($strLastLine);

My instict still points into the userrights direction, so I'd check that.

--
http://www.phpforums.nl
Sep 9 '05 #5
NC
jsw_nz wrote:

I am trying to run an agent application that converts and imports two
tables from MS Access into mySql.
(Intelligent Converters - Access2mySql)
I have run similar scripts to do mysql dumps using the system function.
Not sure if the paths included in the parameters are correct:

<?php
function import_data() {
$sourceFile = "C:\Program Files\Intelligent converters\myAccessDB.mdb";
$tableFile = "C:\Program Files\Intelligent Converters\whichTables.txt";
system("/Program Files/Intelligent Converters/A2SAGENT.EXE
--dest=st_staff --src=$sourceFile --tab_file=$tableFile --mode=1");
}
import_data();
?>

This syntax works fine in command line prompt, but somehow it is not
working when called from php.


It's possible your system doesn't like the space in the command line.
It's also possible that the \'s in variables are treated as escape
symbols.

Try this:

$sourceFile = '"C:\Program Files\Intelligent
converters\myAccessDB.mdb"';
$tableFile = '"C:\Program Files\Intelligent
Converters\whichTables.txt"';
$cl = '"/Program Files/Intelligent Converters/A2SAGENT.EXE" ' .
"--dest=st_staff --src=$sourceFile --tab_file=$tableFile
--mode=1";
system($cl);

Cheers,
NC

Sep 9 '05 #6
Thank you Peter, Paul and NC for your pointers. The space in the path
to the executable was causing the problems. I copied the application to
the root, eliminating any spaces in the path and it now works. So just
a couple of questions/observations

(1) Within the context of calling system commands....is this a general
problem, regardless of the application being called, ie....would I
encounter this in any and all calls using paths that contains spaces.

(2) Paul, you had mentioned that tryiing to escape the spaces in the
path names might help. Familiar with escaping...but not sure how you
would escape the space.

Anyway now works. This forum is great, thanks all for your timely
answers.

John

Sep 9 '05 #7

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

Similar topics

23
by: Spiffy | last post by:
hello, i'm fairly new to python programming and programming in general, but i have written a python prog that creates a MIDI file (.mid) and I want to be able to play it from another prog which is...
24
by: Thom Little | last post by:
During an uninstall, how can I check to see if the application I an uninstalling is currently running? -- -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd. --
1
by: Peter Rilling | last post by:
I have an EXE that I would like to be able to run from either the command-line or as a windows service. Is there a way that I can tell which context the program is running in? Basically, if it...
0
by: Titof | last post by:
Hello, i want to create an active webpage that displays the status of users quotas on a volume of a server. I installed IIS on this server and installed Win2k server Resource Kit because the...
9
by: mareal | last post by:
I have noticed how the thread I created just stops running. I have added several exceptions to the thread System.Threading.SynchronizationLockException System.Threading.ThreadAbortException...
3
by: ° ^F®êâK^ ° | last post by:
Blank hi there, I just want to explain my problem. There is an application which is coded by me running. It is an vb.net application having user controls windows forms and something like visual...
7
by: Mike | last post by:
What i want to do is have my c++ program, run a DOS program and copy a script from that DOS program to a file. I simply have no idea, how, or if it's plausable, to run DOS within a c++ program. ...
3
by: WP | last post by:
Hello, I have a very simple script (or would you call it a batch file?) with the following content: connect to mydb2; DROP TABLE staff_employee_address; DROP TABLE...
1
by: =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post by:
On reflection, you could possibly make the app a self extracting zip file which extracts the EXE and a settings file and then starts the app, then when you app closes, it can repack the settings...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.