我有一个脚本将文件从一个位置复制到另一个位置,我将第一个位置作为参数传递给脚本
<?php
$message = "\": 3,\"title\": \"High score alert!\",\"\": true,\"custom_field\": { \"score\": 51,\"headlines\": \"And now for something completely different...\" }}";
$apiKey = "Your Key";
$registrationIDs = array("Registration id");
$url = 'https://android.googleapis.com/gcm/send';
// Set POST variables
$notify = array(
"alert"=> "great match!",
"title"=> "Portugal vs. Denmark",
"icon" => "myicon",
"badge"=>3,
"vibrate"=>true,
"notification"=>"message"
);
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array( "payload" => $notify,
"notification"=>json_encode($notify)));
$headers = array(
'Authorization: key=' . $apiKey,
'Content-Type: application/json'
);
$ch = curl_init(); // Open connection
curl_setopt($ch, CURLOPT_URL, $url );
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode( $fields ));
var_dump( $url );
var_dump($headers);
var_dump(json_encode( $fields ));
$result = curl_exec($ch); // Execute post
if($result === false)
die('Curl failed ' . curl_error());
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$response = json_decode($result);
print_r($response);
?>
但是当我运行此代码时,会抛出错误 cp:不能统计`locatn&#39;:没有这样的文件或目录 可能是什么问题
答案 0 :(得分:3)
格式化看起来有点奇怪但正如@Patick Trentin所说,你只是忘了$
使你的脚本总是将文件复制到同一位置而忽略给定的参数。
#!/bin/bash
locatn=$1
echo $locate
cp -r /${locatn}/ /ws/priyapan-rcd/workspace/automation/