0
I have a bashscript which uses grep
with awk
as following:
#ec2-describe-instances | grep -i instance | awk '{print "Creating -> " $3; system("ec2-create-image " $2 " --name " $3 "-$(date +%F) --no-reboot ")}'
Unfortunately there seems to be an error.
And unfortunately the console output is empty.
How can I output the errors to console?
1Assuming your prompt is
#
. What happens when you doec2-describe-instances | grep -i instance
-- is there output for awk to consume? – glenn jackman – 2014-05-23T17:41:32.537@glenn jackman - That is one which is a bit strange with this line, scripts usually include a space even for comments, and when they signify a root prompt they include the full prompt, such as 'root@computername:/currentworkingdir#'. The # could be a $, but the ec2-xx cannot be a variable, it must a script name. In that case most user scripts start with ./script unless it is elevated to root. Speaking strictly of bash of course. – arch-abit – 2014-05-23T18:07:47.813
1@arch-abit, if the script is in PATH, then it doesn't require the ./ before it. When I provide BSD commands to customers, I often precede each line with a # and I don't always put a space (either forget or get lazy). In any case, unless we know more about 'ec2-describe-instances' and what it is supposed to output, it is not possible to tell what might be wrong with any thing that manipulates that output. – MaQleod – 2014-05-23T20:46:05.677
@MaQleod - thanks, you are correct. 'Use the PATH, Luke!' :) – arch-abit – 2014-05-23T21:15:51.853