digitalmars.D.learn - Executing AWS commands
- Vino (28/28) Nov 17 2020 Hi All,
- Paul Backus (7/11) Nov 17 2020 You need to break up your command line so that each argument is
- Vino (6/19) Nov 18 2020 Hi Paul,
Hi All, Request your help on how to execute aws commands, below is an example code, and this code is not working, tried several options nothing seem to be working. Code: import std.process: environment, execute; import std.stdio: writeln; void main() { environment["AWS_DEFAULT_REGION"] = "eu-west-1"; auto pid = execute(["/usr/bin/aws ec2 describe-images --filters 'Name=state,Values=available' --query 'Images[*].[ImageId]'"]); if (pid.status != 0) { writeln("Failed"); } else { writeln(pid.output); } } Tried the below(execute, executeShell,spawnProcess,execv) auto pid = execute(["/usr/bin/aws ec2 describe-images --filters 'Name=state,Values=available' --query 'Images[*].[ImageId]'"]); auto pid = execute(["/usr/bin/aws", "ec2 describe-images --filters 'Name=state,Values=available' --query 'Images[*].[ImageId]'"]); auto pid = execute(["/usr/bin/aws", "ec2 describe-images", "--filters 'Name=state,Values=available'", "--query 'Images[*].[ImageId]'"]); auto pid = execute(["/usr/bin/aws", "ec2", "describe-images", "--filters 'Name=state,Values=available'", "--query 'Images[*].[ImageId]'"]); From, Vino.B
Nov 17 2020
On Tuesday, 17 November 2020 at 19:07:42 UTC, Vino wrote:auto pid = execute(["/usr/bin/aws ec2 describe-images --filters 'Name=state,Values=available' --query 'Images[*].[ImageId]'"]);[...]auto pid = execute(["/usr/bin/aws ec2 describe-images --filters 'Name=state,Values=available' --query 'Images[*].[ImageId]'"]);You need to break up your command line so that each argument is in a separate array element. In the commands above you have multiple arguments grouped together into each array element. Alternately, you can pass everything in a single string to `executeShell`.
Nov 17 2020
On Tuesday, 17 November 2020 at 21:08:21 UTC, Paul Backus wrote:On Tuesday, 17 November 2020 at 19:07:42 UTC, Vino wrote:Hi Paul, Thank you very much was able to execute the aws commands using `executeShell`. From, Vino.Bauto pid = execute(["/usr/bin/aws ec2 describe-images --filters 'Name=state,Values=available' --query 'Images[*].[ImageId]'"]);[...]auto pid = execute(["/usr/bin/aws ec2 describe-images --filters 'Name=state,Values=available' --query 'Images[*].[ImageId]'"]);You need to break up your command line so that each argument is in a separate array element. In the commands above you have multiple arguments grouped together into each array element. Alternately, you can pass everything in a single string to `executeShell`.
Nov 18 2020