通过PHP变量到一个Bash脚本,然后启动它 [英] Pass PHP variables to a Bash script and then launch it

查看:110
本文介绍了通过PHP变量到一个Bash脚本,然后启动它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,基本上,我想要做的就是执行这个Bash脚本:

So, basically, what I want to do is execute this Bash script :

#!/bin/bash

path="./"
filename="Ellly.blend"
file=${path}${filename}
description="Test of the api with a simple model"
token_api="ff00ff"
title="Uber Glasses"
tags="test collada glasses"
private=1
password="Tr0b4dor&3"

curl -k -X POST -F "fileModel=@${file}" -F "filenameModel=${filename}" -F "title=${title}" -F "description=${description}" -F "tags=${tags}" -F "private=${private}" -F "password=${password}" -F "token=${token_api}" https://api.sketchfab.com/v1/models

里面一个PHP函数。问题是,我真的不知道怎样才能传递给它的一些变量,然后等待它恢复PHP函数之前结束。

Inside a PHP function. Problem is, I don't really see how I can pass to it some variables and then wait for it to end before resuming the PHP function.

任何帮助吗?

推荐答案

注:我没有做的所有设置,刚好够我希望你的想法

PHP:

$output = exec("./bashscript $file $filename $tags $private $password");

#!/bin/bash

击:

filename=$1
file=$2
description="Test of the api with a simple model"
token_api="ff00ff"
title="Uber Glasses"
tags=$3
private=$4
password=$5

...


选项2:使用环境变量

PHP:

putenv("FILENAME=$filename");
putenv("FILE=$file");
putenv("TAGS=$tags");
putenv("PRIVATE=$private");
putenv("PASSWORD=$PASSWORD");

$output = exec('./bash_script');

击:

filename=$FILENAME
file=$FILE
description="Test of the api with a simple model"
token_api="ff00ff"
title="Uber Glasses"
tags=$TAGS
private=$PRIVATE
password=$PASSWORD

...

这篇关于通过PHP变量到一个Bash脚本,然后启动它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆