MidwestTapes
asked on
Store the error output of a command in shell script
I am able to store the output of a command when it completes successfully.
example
#!/bin/sh
createimage=$(aws ec2 create-image --instance-id i-bb68f5df --name ftp.b2b.backup.12-1 --no-reboot --description ftp.b2b.backup.test)
echo "$createimage"
script returns
{
"ImageId": "ami-f5113e9c"
}
however when the command fails in the script the output is not being stored in the createimage variable.
example
#!/bin/sh
createimage=$(aws ec2 create-image --instance-id i-bb68f5df --name ftp.b2b.backup.12-1 --no-reboot --description ftp.b2b.backup.test)
echo "$createimage"
script returns
{
"ImageId": "ami-f5113e9c"
}
however when the command fails in the script the output is not being stored in the createimage variable.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It means: send error messages (2) to regular output (&1)
ASKER
Thank you
ASKER