473,395 Members | 1,616 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,395 software developers and data experts.

System call

Hello,

I have UI in php,
windows bat file that, i want to run bat file from UI,this file
contains
[code in bat file]
java snmp
[/code]

it run the snmp class file that in java code,
"All i want it to call it form UI or call java with snmp class file"

i got some example of system call function but all r for *nix not for
win box, i used same but it's not working what to do?


Thanks
VM
Jun 27 '08 #1
5 1571
BigZero wrote:
Hello,

I have UI in php,
windows bat file that, i want to run bat file from UI,this file
contains
[code in bat file]
java snmp
[/code]

it run the snmp class file that in java code,
"All i want it to call it form UI or call java with snmp class file"

i got some example of system call function but all r for *nix not for
win box, i used same but it's not working what to do?


Thanks
VM
system() and related functions work on Windows, also. But "it's not
working" doesn't tell us anything.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #2
On Jun 23, 10:56 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
BigZero wrote:
Hello,
I have UI in php,
windows bat file that, i want to run bat file from UI,this file
contains
[code in bat file]
java snmp
[/code]
it run the snmp class file that in java code,
"All i want it to call it form UI or call java with snmp class file"
i got some example of system call function but all r for *nix not for
win box, i used same but it's not working what to do?
Thanks
VM

system() and related functions work on Windows, also. But "it's not
working" doesn't tell us anything.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
ok,
when i tryed this
exec("C:\\Admin_Works\\Admin.bat");
it prints the two line form the admin.bat file

Thanks
VM
Jun 27 '08 #3
BigZero wrote:
On Jun 23, 10:56 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>BigZero wrote:
>>Hello,
I have UI in php,
windows bat file that, i want to run bat file from UI,this file
contains
[code in bat file]
java snmp
[/code]
it run the snmp class file that in java code,
"All i want it to call it form UI or call java with snmp class file"
i got some example of system call function but all r for *nix not for
win box, i used same but it's not working what to do?
Thanks
VM
system() and related functions work on Windows, also. But "it's not
working" doesn't tell us anything.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

ok,
when i tryed this
exec("C:\\Admin_Works\\Admin.bat");
it prints the two line form the admin.bat file

Thanks
VM
exec() executes a program. A .bat file is not a program. You need to
either execute the command processor (cmd.exe) and pass your .bat
filename as a parameter, or use the system() function.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #4
Greetings, Jerry Stuckle.
In reply to Your message dated Tuesday, June 24, 2008, 14:53:26,
>when i tryed this
exec("C:\\Admin_Works\\Admin.bat");
it prints the two line form the admin.bat file
Read PHP manual about "exec" and other program execution functions.
If you do not have a "@" prepending lines in your bat file, or "echo off" as
first line, CMD will print out content of bat file. That's what you got.
exec() executes a program. A .bat file is not a program. You need to
either execute the command processor (cmd.exe) and pass your .bat
filename as a parameter, or use the system() function.
As I said many times already, please test before posting answers.
..bat files actually executable in Windows (special processing rule).
And it is what OP got - his bat file was executed by CMD and he got the .bat
file contents echoed back.

[C:\]$type exectest.php
<?php

$rc = exec('C:\exectest.bat');

echo "Result is >{$rc}<";

?>
[C:\]$type exectest.bat
@echo Testtestetst...

[C:\]$exectest.php
Result is >Testtestetst...<

[C:\]$
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #5
Greetings, Jerry Stuckle.
In reply to Your message dated Wednesday, June 25, 2008, 06:02:44,
AnrDaemon wrote:
>Greetings, Jerry Stuckle.
In reply to Your message dated Tuesday, June 24, 2008, 14:53:26,
>>>when i tryed this
exec("C:\\Admin_Works\\Admin.bat");
it prints the two line form the admin.bat file

Read PHP manual about "exec" and other program execution functions.
If you do not have a "@" prepending lines in your bat file, or "echo off" as
first line, CMD will print out content of bat file. That's what you got.
>>exec() executes a program. A .bat file is not a program. You need to
either execute the command processor (cmd.exe) and pass your .bat
filename as a parameter, or use the system() function.

As I said many times already, please test before posting answers.
.bat files actually executable in Windows (special processing rule).
And it is what OP got - his bat file was executed by CMD and he got the .bat
file contents echoed back.

[C:\]$type exectest.php
<?php

$rc = exec('C:\exectest.bat');

echo "Result is >{$rc}<";

?>
[C:\]$type exectest.bat
@echo Testtestetst...

[C:\]$exectest.php
Result is >Testtestetst...<

[C:\]$

Believe me - I know how it works. I suspect I've working with it a hell
of a lot longer than you - I got one of the original IBM PC's with Dos
1.0 over 25 years ago.
It was your first PC? How young you are then?
What you say is true - depending on what other options are set.
It just true, without any "depending"s...
Please TEST it.
But he also indicated that was the ONLY output he got.
Then it was problem with his batch file or misunderstanging of the way the
exec function works.
But it has nothing to do with PHP itself.
And .BAT files are executed ONLY if special rules are set.
As far as I know, they are set by default. At least, I haven't entered the
situation, when I can't "execute" .bat file from PHP.
system() ALWAYS can execute a .bat file.
So, as usual, you are showing your limited intelligence and experience,
because what you say is valid only under certain conditions.
My example ^^^ above. You showed nothing to prove your words.
Who is right? One who tested.
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #6

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

Similar topics

1
by: Erik Johnson | last post by:
Hi, I am trying to spawn a daemon type program to go off on its own and do some work (asynchoronously) from within an HTTPServer, but I am running into a problem where the web browser (actually...
7
by: rahul8143 | last post by:
hello, what is difference between system call and library function call? Does library function call can have context switch to kernel mode? regards, rahul
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
7
by: RobKinney1 | last post by:
Hello, Wow...I have one for you all and hopefully I am not understanding this timer object correctly. I have a timer setup that pulses a connection through a socket every 60 seconds. But it...
6
by: leoman730 | last post by:
This is one of the interview question this morning, hope someone can help out with this. Thanks. What is the different between System call and library call?
21
by: omkar pangarkar | last post by:
Hi all, I have two simple hello world programs one using printf() and other using write() --prog 1-- #include<stdio.h> #include<stdlib.h> int main() { printf("Hello"); /* up to here...
1
by: sophia.agnes | last post by:
Dear all, I was going through peter van der linden's book expert C programming there i found the following:- Library call ------------ *call to a routine in a library *linked with user...
35
by: jleslie48 | last post by:
I've written a cgi program in C using the borland 5.5 free compiler, and it runs just fine on an Apache server. My only issue is if I issue some system calls the cgi suspends until the call...
2
by: Radz | last post by:
when the fork system call is executed, a new process is created. The original process is called the parent process whereas the new process is called the child process. The new process consists of a...
0
ashitpro
by: ashitpro | last post by:
Writing System Call Wrappers in User Space. Recently I saw a post in Linux/Unix section to know the user who deleted the file in linux. Currently there is nothing in linux which could achieve...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.