Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to run a PHP file (with arguments) from Win Batch File (with arguments)  ??

Posted on 2013-06-03
4
Medium Priority
?
981 Views
Last Modified: 2013-06-03
I'm trying to run a batch file with an argument, which in turn passes that argument to a php file and runs.... I've tried a few different things but cant seem to get it working. Heres what I have:

process.bat (passed with a full path to a file (%1))

"C:\Program Files (x86)\PHP\php.exe" C:\inetpub\wwwroot\Label.php?File=%1
PAUSE

Open in new window


The above fails to run the PHP script with the following error:#

Could not open input file: C:\inetpub\wwwroot\Label.php?File=%1?File=C:\WatchFolder\label1.txt

Does anyone know how I can correctly pass the %1 batch file argument through to the PHP script?

Thanks
0
Comment
Question by:Bergstr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 10

Expert Comment

by:rjanowsky
ID: 39215763
Did you check this document: PHP Command Line on Microsoft Windows? There are some concrete infos to get it running.
0
 

Author Comment

by:Bergstr
ID: 39215810
I don't think the problem is running a PHP file from a batch file (I've already got that working) - the bit I cant work out is how to get the variable from the batch file into the PHP, and then utilise the variable within the PHP,

Since I first posted, I've noticed the following DOES work, but I cant figure out how you get PHP to read the argument data.

"C:\Program Files (x86)\PHP\php.exe" C:\inetpub\wwwroot\Label.php %1

Open in new window

^ works

"C:\Program Files (x86)\PHP\php.exe" C:\inetpub\wwwroot\Label.php?File=%1

Open in new window

^ Doesn't work

I've tried using $argv but cant echo that into a file? i'm going to try running a loop on the $argv and see if that works, will report back with how I get on!
0
 
LVL 7

Accepted Solution

by:
msifox earned 2000 total points
ID: 39215890
$argv is an array.
$argv[1] is the first argument that you specified.
0
 

Author Comment

by:Bergstr
ID: 39216000
that worked! thank you!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question