我的PowerShell脚本如下所示,位于文件myps.ps1
中。
Invoke-Expression "terraform apply -auto-approve" -OutVariable COMMAND_OUTPUT 2>&1 >$null
通过这个脚本,我试图将标准错误和标准输出捕获到变量$COMMAND_OUTPUT
中。但是,当terraform apply
命令引发错误时,在...
中会捕获到以省略号($COMMAND_OUTPUT
)结尾的截断的错误消息。
如何在$COMMAND_OUTPUT
变量中捕获整个PowerShell控制台输出而不会被截断。
答案 0 :(得分:0)
<?php
class Autocomplete extends CI_Controller{
function __construct() {
parent::__construct();
$this->load->model('datacomplete');
}
public function index(){
$data['posts'] = $this->datacomplete->information();
$this->load->view('view_demo',$data);
}
public function GetCountryName(){
$keyword=$this->input->post('keyword');
$data=$this->datacomplete->GetRow($keyword);
echo json_encode($data);
}
public function search()
{
$this->load->view('search',$data);
}
}
?>
This is model
<?php
class Datacomplete extends CI_Model{
public function GetRow($keyword) {
$this->db->order_by('id', 'DESC');
$this->db->like("name", $keyword);
return $this->db->get('autocomplete')->result_array();
}
public function information()
{
$this->db->select("id");
$this->db->from('autocomplete');
$query = $this->db->get();
return $query->result();
}
}
?>
This is view code
<!DOCTYPE html>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="<?php echo base_url(); ?>assets/custom.js"></script>
</head>
<body style="background-color: white;">
<?php foreach($posts as $post)
{
echo $post->id;
}
?>
<form action="<?php echo base_url('autocomplete/search?id=$post['id']'); ?>" method="post">
<div class="row">
<center><h2 style="color: #fff;">AUTOCOMPLETE FORM FROM DATABASE USING CODEIGNITER AND AJAX</h2></center>
<div class="col-md-4 col-md-offset-4" style="margin-top: 200px;">
<label class="control-lable" style="color: #fff;">Country Name</label>
<input style="height:70px" type="text" id="country" autocomplete="off" name="country" class="form-control" placeholder="Type to get an Ajax call of Countries">
<ul class="dropdown-menu txtcountry" style="margin-left:15px;margin-right:0px;" role="menu" aria-labelledby="dropdownMenu" id="DropdownCountry"></ul><button location.href='<?php echo site_url().'/autocomplete/search?id='.$post['id'];?>' type="submit">Submit</button>
</div>
</div>
</form>
</body>
</html>
This is custom.js
$(document).ready(function () {
$("#country").keyup(function () {
$.ajax({
type: "POST",
url: "http://localhost/codeajax/autocomplete/GetCountryName",
data: {
keyword: $("#country").val()
},
dataType: "json",
success: function (data) {
if (data.length > 0) {
$('#DropdownCountry').empty();
$('#country').attr("data-toggle", "dropdown");
$('#DropdownCountry').dropdown('toggle');
}
else if (data.length == 0) {
$('#country').attr("data-toggle", "");
}
$.each(data, function (key,value) {
if (data.length >= 0)
$('#DropdownCountry').append(
'<li role="displayCountries" ><a role="menuitem dropdownCountryli" class="dropdownlivalue">' + value['name'] + '</a></li>');
});
}
});
});
$('ul.txtcountry').on('click', 'li a', function () {
$('#country').val($(this).text());
});
});
是considered harmful,对于您遇到的任何问题,几乎总是错误的工具。
要捕获变量中的命令输出(包括错误),请使用以下内容:
Invoke-Expression