开发者

GET php data to a commandline prompt

A PHP application on the server is saving a certain document with a sequential number into a MySQL database. How to obtaion that sequential number to a command line prompt that initiates the local doocument scanner?

ex:

c:\myscan ask_for_current_seq_nmbr.pdf

myscan is something written in c that takes care of the PC stuff. Only the name of file is unknown.

Some code (from the query PHP file)

$query = "SELECT last_seq FROM seq_table WHERE cat = 1";

$result = mysql_query($query, $link) or die('ERROR: '. mysql_err开发者_运维问答or().'<br />ON LINE: '.__LINE__);

while($row = mysql_fetch_assoc($result)) {
    echo $row['last_seq'];
}

!!! NOTE !!! I am fetching a page from a remote server. ex. www.site.com/query.php?q=SELECT * FROM... And that selection results in the last used sequential number which I would like to use in my command prompt.

!! UPDATE !!

We HAVE to go through a PHP file on the remote server to avoid having to use Remoote MySQL which has to be enabled on an IP basis.


You can call processes that run on the commandline with various function from PHP from the exec familyDocs.

If you're having problems building the actual command string, you can do with:

$cmd = sprintf('c:\myscan %d.pdf', $sequential_number);

As you write that the script is already writing it into the db with the $sequential_number I assume you have it already.

In case the database generates the number, then probably as the primary key. See mysql_insert_idDocs for obtaining the id.


Okay judging by the backslash and the C:\ I am guess you're using windows.

You are going to have to combine the following:

http://dev.mysql.com/doc/refman/5.5/en/mysql.html

How to store the result of a command expression in a variable using bat scripts?

and then to access the content of the variable you created use the %VARIABLE_NAME% syntax.


You should have flag in your mysql table like is_processed with value = 0 or 1. When scan starts it runs query:

SELECT * FROM TABLE where is_processed = 0 order by sec_number

After processing you should run query:

UPDATE TABLE set is_processed = 1 where sec_number = 'sec_processed_number';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜