Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
setting the target of a program when using exec or shell_exec
Old 10-04-2008, 05:27 PM setting the target of a program when using exec or shell_exec
Novice Talker

Posts: 8
Trades: 0
Hello!

I want to use exec to execute a shoutcast server in c:\shoutcast\sc_serv.exe on my Windows server 2003 IIS server. So I use this code
PHP Code:
<?php exec("c:\shoutcast\sc_serv.exe");  ?>
It does execute the program, however, it's making the target of the program c:\windows\system32. Seeing as the configuration file for the sc_serv.exe is in c:\shoutcast\sc_serv.exe, it cannot find the configuration file. I need to somehow tell PHP that I want it to launch sc_serv.exe but with a target of d:\shoutcast ..

So I tried this:
PHP Code:
<?php shell_exec("cd c:\shoutcast");  shell_exec("sc_serv.exe"); ?>
But it executed it both commands as if it opened CMD, ran the first command, closed CMD, opened a NEW CMD and ran the last command. It didn't work.

If anyone could help me, I would REALLY appreciate it!
macmee is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-04-2008, 06:03 PM Re: setting the target of a program when using exec or shell_exec
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
There's probably a better way, but since you're on a Windows box, create a .bat file with those 2 commands in it and just call it. May want to add @echo off to it.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 10-04-2008, 06:10 PM Re: setting the target of a program when using exec or shell_exec
Novice Talker

Posts: 8
Trades: 0
Quote:
Originally Posted by JeremyMiller View Post
There's probably a better way, but since you're on a Windows box, create a .bat file with those 2 commands in it and just call it. May want to add @echo off to it.
That's a very good suggestion, however for each different shoutcast server I want to run, I'd have to create a batch file . The code I gave was a simplified code of what I'm really going to have. I wanted to have something along the lines of
PHP Code:
shell_exec("cd " $path); 
.

Last edited by macmee; 10-04-2008 at 06:11 PM..
macmee is offline
Reply With Quote
View Public Profile
 
Old 10-04-2008, 06:12 PM Re: setting the target of a program when using exec or shell_exec
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Well, batch files can take parameters. I believe you reference them by %1, %2, ... but you'd have to check that. You could then execute the batch file, pass the parameter and have what you want.


Also, you might be able to put both commands directly into the exec, separated by semicolons, but I don't remember enough batch programming to recall.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 10-06-2008, 03:55 AM Re: setting the target of a program when using exec or shell_exec
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
exec("cd c:\folder\ ; c:\shoutcast\sc.exe");
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to setting the target of a program when using exec or shell_exec
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21772 seconds with 12 queries