考虑以下示例:
Parameter1 = 5
Parameter2 = 10
Parameter3 = 15
Parameter4 = 20
我想通过提供如下所示的用户输入来取决于参数名称来获取值:
echo ""
echo " Enter the parameter name"
read value
Parameter = "$value"
检查参数是否存在于关注文件中
if grep -qs "$Parameter" "Filename"
then
echo " Parameter exist within the concern file"
val = #Here I want to fetch the value of the parameter that the user had input and I do not know how to do it?
请告诉我如何获取用户输入的参数值。
答案 0 :(得分:0)
如果我理解正确,你可以使用这样的东西:
public function chargeCustomer ()
{
$plan = Input::get('plan'); $token = Input::get('stripeToken');
if($plan == 'ito_monthly')
{
Auth::user()->subscription($plan)->create($token);
return redirect('/dashboard');
}
elseif($plan == 'ito_yearly')
{
Auth::user()->subscription($plan)->create($token);
return redirect('/dashboard');
}
elseif($plan == 'pay-per-item')
{
return "to be impleamented later";
}
}
public function updateCard()
{
$cu = \Stripe\Customer::retrieve("cus_7evdSA5ccyyGc2");
}
User::setStripeKey(\Config::get('services.stripe.secret')) this is set in appserviceprovider under boot().
这将读取参数的名称,然后在第一个字段与名称匹配时在行上打印第三个字段。结果将分配给shell变量read param_name # e.g. Parameter2
value=$(awk -v param="$param_name" '$1 == param { print $3 }' filename)
。