How to execute a linux executable file in linux server using shell_exec in php?

Discussion in 'PHP' started by chetan1989, Jul 9, 2008.

  1. #1
    made a php program in windows server and here is my code:

    $cmdline = "filename"
    $result = shell_exec($cmdline);

    /directory
    -index.php
    -folder_containing_resource
    -filename

    the file uses a resource that is in the folder residing in the current directory( directory where php page is)


    now i need to upload my work in a linux server. what will be the right command in using shell_exec()?
    i know that what i used in my program is a windows executable file so i will provide a linux executable file for this.

    i just need to know the command in linux in order for my project to work. thanks in advance.
     
    chetan1989, Jul 9, 2008 IP
  2. Kwaku

    Kwaku Well-Known Member

    Messages:
    1,217
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    140
    #2
    What you state above should work fine ; you can just run;

    $result = `./filename`;

    make sure the filename has perms 555 (or something like that)
     
    Kwaku, Jul 10, 2008 IP
  3. revvi

    revvi Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can use this too:

    
    $filename='/home/username/file_name_here'; // this is just an example of the file path;
    system($filename);
    
    PHP:
     
    revvi, Jul 10, 2008 IP