Running an rsync shell command through a PHP script in a web browser

At first, our objective is to transfer modifications from one system to another using a shell script named synchfolders.sh. The content of the file is as follows:

rsync -av --delete -e 'sshpass -p Wordpress@123 ssh -p 22' <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="93e1fcfce7d3a2aaa1bda2a5abbda1bdaaa7">[email protected]</a>:/var/www/html/prosync/wp-content/plugins/ /var/www/html/devsync/wp-content/plugins >> /var/www/html/devsync/wp-content/mysynclog.txt

We aim to run this shell script in a PHP file using shell_exec(). However, when executing this PHP file from a web browser, everything runs except for the rsync command. After browsing Stack Overflow, we came across this post: php exec() rsync ssh to remote server not working. The solution suggested was to test running the PHP file from the command line, which worked perfectly fine. Unfortunately, it still does not work through the browser. Could you please point out where we might have gone wrong? Thank you in advance.

Answer №1

Please input the complete path for the rsync command:

/usr/bin/rsync -av --delete -e 'sshpass -p Pass@123 ssh -p 22' <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7d4f52525c06737b706c67652b2321">[email protected]</a>:/var/www/html/prosync/wp-content/plugins/ /var/www/html/devsync/wp-content/plugins >> /var/www/html/devsync/wp-content/log.txt

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What could be causing the issue where only the latest data is being shown

When I use ajax to retrieve data from my database, the console.log displays all the results correctly, but in my HTML, only the last result is shown. What could be causing this issue? Any help would be appreciated! Thanks! Please keep your response simple ...

Passing variables from AJAX response to PHP using a passthru function

In my PHP file, I have implemented a functionality where certain checkboxes are checked and upon clicking a button, a JavaScript file is triggered. The JavaScript code snippet used is as follows: $.ajax ({ type: "POST", url: "decisionExec.php", ...

An application that combines the functionality of a desktop program with online server features and database integration

I'm currently developing a desktop application using electron and contemplating utilizing online storage to save data. I've scoured the internet for answers but can't seem to find reliable information. One possible approach is to integrate ...

consolidating various data into a single field

In order to personalize the user experience, I aim to provide individuals with the ability to choose their academic majors. For instance, a student named Person A may opt for computer science, mathematics, and history as their chosen fields of study. User ...

Enhanced Slider Display featuring Multiple Posts for Improved Performance

My Sample Page features a slider that displays over 200 posts, each containing 5 images. However, the slider loads all the images at once, causing my page speed to be very slow. I am looking for an optimized way to display the slider without compromising l ...

Page can be accessed using file_get_contents function but not with cURL

In the process of creating an API endpoint in PHP, a scenario arose where JSON data output from a specific page example.com/stats was causing issues with cURL requests compared to using file_get_contents(). How can I ensure that JSON data served in PHP is ...

Is it possible for the WordPress Polylang function `pll_the_languages()` to return an empty string instead of the switcher

Having trouble displaying the polylang switcher on my custom WordPress theme's header.php file. $mlkLng = pll_the_languages(); var_dump( $mlkLng ); //this returns a string(0) "" I have 3 languages on my site, which I can confirm using the ...

Transform your cURL command to cURL PHP code equivalent

I am new to cURL and AJAX. I have been trying to learn on my own, but I am struggling to figure out how to convert a cURL CMD script into a cURL PHP script. Below is my cURL CMD script: curl 'https://example.url' ^ -H 'authority: example. ...

Tips for sending PHP variables together with a Typeahead variable

I have simplified this code as much as possible. I have a typeahead variable that is functioning correctly. However, I also need to pass two unrelated variables $php_var1 and $php_var2 along with the typeahead variable. These PHP variables are initialized ...

Transmitting an array via Ajax

Is there a way to pass an array from JavaScript to PHP using Ajax? var selectedCheckboxes = $('.def-mask :checkbox:checked').serialize(); $.ajax({ url: 'ajax/battle.php', type: 'post', data: { playerReady: 1, atta ...

Adjust input quantities for product variations in Woocommerce

In my WooCommerce store, I encountered an issue with a variable product that has 3 product variations. Unfortunately, the quantity to sell for each variation needs to be fixed and cannot be adjusted by the customer. For instance: We have 2 Red items ava ...

Initiate and terminate npm using a PHP script

Can you launch npm from a PHP script using the browser? For instance, by implementing the following code? // start.php echo exec('npm run forever'); die(); And to halt node execution: // stop.php echo exec('npm run stopforever'); die ...

Encountering an error in a Laravel application when attempting to return JSON data using

After submitting my page, I am trying to display any validation errors underneath the appropriate form field if there are any. Currently, I am encountering an error in my console. If you could take a look at the code and suggest any changes to improve it, ...

Restructuring XML using SimpleXML

Currently, I am working on developing an API that will enable data transfer from Magento to my POS system. To ensure compatibility with my POS supplier's requirements, I need to write the data in XML 1.0 format based on a specific code provided by the ...

Is there a way to eliminate a variable name from a URL using htaccess?

Essentially, I am looking to allow users to access my website using a URL like /45678, as opposed to the traditional /?p=45678. The goal is to eliminate the variable name from the URL. I attempted to achieve this by utilizing mod_rewrite, but it appears th ...

Processing incoming requests with a loading interface in CodeIgniter

Is there a way to notify the user who sent the request whether or not the requested user will approve it? Optional: If there is no notification sent to the user who made the request, the requested user will have to wait for verification. For Example: Ima ...

Obtaining substrings following a character with different lengths

I am currently working on developing a code that will enable me to extract specific characters following a string. I have provided two examples of such strings below: End Table Brand New $50 Dimensions: 26"x18"x18" Assembly required Color: Black ...

The AJAX request to send data to PHP is not functioning correctly

I have an issue where I am trying to send data to my server using AJAX in PHP. Even though I have set the method as POST, it seems to be executing as a GET request instead. Here is the code snippet: $.ajax({ type: 'POST', data: { user: us ...

Is there a method to prevent unphar-ing a phar file (PHP Archive)?

Have you heard about the handy tool in php that allows you to archive php files in "phar" format for easy distribution and installation? This tool can create a single "phar" file of an entire php folder. http://www.php.net/manual/en/intro.phar.php Additio ...

Calculate the distance between two locations by utilizing the Google Maps API to determine driving time

Can someone assist with displaying the time format like 16:00 in PHP? function CalculateTime($lat1, $lat2, $long1, $long2) { $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=".$lat1.",".$long1."&destinations ...