我有以下代码,aws命令仅适用于sudo
#!/usr/bin/perl
use strict;
use warnings;
my $ogg_file = '20191220-104756_4301_1571528872-480639.ogg';
unless (system ('aws', 's3','cp', $ogg_file, "s3://recordings")==0) {
print STDERR "Failed to upload '$ogg_file': $!\n";
next;
}
我尝试使用sudo运行,但无法正常工作。谁能建议我一个更好的方法
答案 0 :(得分:1)
尝试更改
system ('aws', 's3','cp', $ogg_file, "s3://recordings")
...进入其中之一:
system(qq(sudo aws s3 cp "$ogg_file" "s3://recordings"))
system("sudo aws s3 cp '$ogg_file' s3://recordings")
答案 1 :(得分:0)
您也可以执行以下操作以提高可读性
private Random rnd = new Random();
private void btnBarkodOlustur_Click(object sender, EventArgs e)
{
string _newBarcode = BarcodeGenerator();
while (context.Stocks.Any(c => c.Barcode == _newBarcode) || context.Units.Any(c => c.Unit == _newBarcode))
{
_newBarcode = BarcodeGenerator();
}
txtBarcode.Text = _newBarcode;
}
private string BarcodeGenerator()
{
return rnd.Next(10000000, 99999999);
}