php, rsync and exec function

Posted on 2004-11-14
Last Modified: 2012-08-13
I need from a PHP script running .""  that contain  :

SSH_AUTH_SOCK=/tmp/ssh-XXlFi8Jl/agent.3825; export SSH_AUTH_SOCK;
echo Agent pid 3826;
/usr/bin/rsync --delete -ave ssh /data/AUDIO_FILES/ srv01:/data/AUDIO_FILES/

In my php script :

exec("/home/  2>&1",$return);

print_r($return) give me :

Array ( [0] => Agent pid 3826 [1] => Could not create directory '/.ssh'. [2] => Host key verification failed. [3] => unexpected EOF in read_timeout )

Question by:eeolivier

    Author Comment

    Maybe you could tell me how to execute a script with root rights, and with all PATH ok ? maybe it's the problem ?
    LVL 48

    Expert Comment

    See http:Q_21108456.html how to setup sudo to work with the webserver user, so you can run that script as root.

    Author Comment

    no, nothing there that can help me
    LVL 48

    Accepted Solution

    add in /etc/sudoers:
    wwwrun  ALL=(ALL) NOPASSWD: /home/

    in php call exec('sudo /home/', $return);
    Then your script will be run as root.

    What do you want to do with that script exactly. Seems that you want to connect to an running ssh-agent. Are you sure that that agent still exists and under which user is thatagent running?

    Author Comment

    yes, that script run perfectly when I run it from the shell as root.

    It let me to synchronize files over 5 different servers avec over SSH without having to type password.

    When i do vi /etc/sudoers, under root user, i have "read only file".

    Author Comment

    it was "visudo". I am going to try the tip

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Don't send email 6 47
    Generating Excel in php 5 31
    why can I not use ELSE like this? 13 40
    Total days in a month 12 27
    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now