簡體   English   中英

無法通過 PHP 執行 .sh 文件

[英]Cannot Execute a .sh file by PHP

我正在嘗試通過 .sh 文件備份數據庫。 如果我手動打開文件,它工作正常。 但我正在嘗試使用 PHP(laravel) 來實現。

這是我的 mysql_backup.sh 文件:

#!/bin/bash

#
#   Use this script to perform backups of one or more MySQL databases.
#

# Databases that you wish to be backed up by this script. You can have any number of databases specified; encapsilate each database name in single quotes and separate each database name by a space.
#
# Example:
# databases=( '__DATABASE_1__' '__DATABASE_2__' )
databases=('sasty')

# The host name of the MySQL database server; usually 'localhost'
db_host="127.0.0.1"

# The port number of the MySQL database server; usually '3306'
db_port="3306"

# The MySQL user to use when performing the database backup.
db_user="root"

# The password for the above MySQL user.
db_pass=""

# Directory to which backup files will be written. Should end with slash ("/").
backups_dir="C:/Users/Kapil/backup/"

backups_user=""

# Date/time included in the file names of the database backup files.
datetime=$(date +'%Y-%m-%dT%H:%M:%S')

for db_name in ${databases[@]}; do
        # Create database backup and compress using gzip.
        C:/xampp/mysql/bin/mysqldump -u $db_user -h $db_host -P $db_port --password=$db_pass $db_name | gzip -9 > $backups_dir$db_name--$datetime.sql.gz
done

# Set appropriate file permissions/owner.
chown $backups_user:$backups_user $backups_dir*--$datetime.sql.gz
chmod 0400 $backups_dir*--$datetime.sql.gz

我為此使用 PHP 代碼

shell_exec('/path/to/my/file');

但它不起作用。 但是 shell_exec('ls') 工作正常。 如何解決我的問題?

配置文件

disable_functions =exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source

刪除 shell_exec

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM