当前位置: 技术问答>linux和unix
参数的传入
来源: 互联网 发布时间:2015-12-25
本文导语: 在SHEE脚本中有以下的命令: /xxx/php xxx.php 想在SOLARIS命令行中执行SHELL,然后向PHP程序传递参数.但是参数也要在SOLARIS命令行中输入.请问大人们怎么去实现这个功能.在SHELL中写如参数的方法知道,就是在命令/xxx/php xx...
在SHEE脚本中有以下的命令:
/xxx/php xxx.php
想在SOLARIS命令行中执行SHELL,然后向PHP程序传递参数.但是参数也要在SOLARIS命令行中输入.请问大人们怎么去实现这个功能.在SHELL中写如参数的方法知道,就是在命令/xxx/php xxx.php 的后边写如参数,有几个就写几个.但是从SOLARIS的命令行传递参数的方法不知道.请高人指点.
/xxx/php xxx.php
想在SOLARIS命令行中执行SHELL,然后向PHP程序传递参数.但是参数也要在SOLARIS命令行中输入.请问大人们怎么去实现这个功能.在SHELL中写如参数的方法知道,就是在命令/xxx/php xxx.php 的后边写如参数,有几个就写几个.但是从SOLARIS的命令行传递参数的方法不知道.请高人指点.
|
i do not understand your questions very clearly. i will answer your questions based on my own understanding.
For example, the shell script name is myshellscript, i assume you use C/TC shell.
on command line
ocor>:./myshellscript arg1 arg2 arg3 arg4
Then in your script, you can use the following statements to set arg1, arg2... as the arguments of your php program.
/xxx/php xxx.php $1 $2 $3 # the $1 is the first arg, $2 is the 2nd and so on, $0 is the script name. you can use echo $0 $1 $2 $3 to output the arg
you can download the "UNIX® Shells by Example Fourth Edition" ebook which is very good for shell programming beginner.
For example, the shell script name is myshellscript, i assume you use C/TC shell.
on command line
ocor>:./myshellscript arg1 arg2 arg3 arg4
Then in your script, you can use the following statements to set arg1, arg2... as the arguments of your php program.
/xxx/php xxx.php $1 $2 $3 # the $1 is the first arg, $2 is the 2nd and so on, $0 is the script name. you can use echo $0 $1 $2 $3 to output the arg
you can download the "UNIX® Shells by Example Fourth Edition" ebook which is very good for shell programming beginner.
|
shift
|
shift 就可以了