shell_exec

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pradeep

    #1

    shell_exec

    Hello,

    I want to copy file from remote machine to local machine using PHP.
    On both machines Linux operating system present.

    The code is

    $result=shell_e xec("scp admin@192.168.1 .236:/mnt/disc/hda/part1/demo/
    conn /opt/lampp/htdocs/upload/");

    This function return nothing & file is not copied.
    If I use above parameter on konsole , it copy successfully.

    Please, guide me.

  • Erwin Moller

    #2
    Re: shell_exec

    pradeep wrote:
    Hello,
    >
    I want to copy file from remote machine to local machine using PHP.
    On both machines Linux operating system present.
    >
    The code is
    >
    $result=shell_e xec("scp admin@192.168.1 .236:/mnt/disc/hda/part1/demo/
    conn /opt/lampp/htdocs/upload/");
    >
    This function return nothing & file is not copied.
    If I use above parameter on konsole , it copy successfully.
    >
    Please, guide me.
    Hi

    Could it be a permissionprobl em?
    PHP runs as 'www-data' or 'apache', or' nobody'.
    To debug you could try the following:
    1) log in as the user PHP is. (Use touch somefile from PHP on some wideopen
    directory to check if unsure)
    2) give the command in Konsole

    Does THAT work?

    If yes, well, I would advise you to catch the output produced by the
    command.
    Use passthry() to catch the output. Maybe it contains some error that helps
    you fix the problem.

    Regards,
    Erwin Moller

    Comment

    • Erwin Moller

      #3
      Re: shell_exec

      Erwin Moller wrote:
      pradeep wrote:
      >
      >Hello,
      >>
      >I want to copy file from remote machine to local machine using PHP.
      >On both machines Linux operating system present.
      >>
      >The code is
      >>
      >$result=shell_ exec("scp admin@192.168.1 .236:/mnt/disc/hda/part1/demo/
      >conn /opt/lampp/htdocs/upload/");
      >>
      >This function return nothing & file is not copied.
      >If I use above parameter on konsole , it copy successfully.
      >>
      >Please, guide me.
      >
      Hi
      >
      Could it be a permissionprobl em?
      PHP runs as 'www-data' or 'apache', or' nobody'.
      To debug you could try the following:
      1) log in as the user PHP is. (Use touch somefile from PHP on some
      wideopen directory to check if unsure)
      2) give the command in Konsole
      >
      Does THAT work?
      >
      If yes, well, I would advise you to catch the output produced by the
      command.
      Use passthry() to catch the output. Maybe it contains some error that
      helps you fix the problem.
      [typo correction]
      That should have been passthru(). :-)
      >
      Regards,
      Erwin Moller

      Comment

      • C.

        #4
        Re: shell_exec

        On 1 Mar, 09:51, Erwin Moller
        <since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
        pradeep wrote:
        $result=shell_e xec("scp a...@192.168.1. 236:/mnt/disc/hda/part1/demo/
        conn /opt/lampp/htdocs/upload/");
        >
        >
        Could it be a permissionprobl em?
        If its running as a different user it will be looking in a different
        place for the private key to connect.

        C.

        Comment

        Working...