0

I am attempting to send an email using a BASH script and it works fine but I am unable to set the From Address. I am using the mailx command. I am always met with the mailx: illegal option -- r error. Here is what my code looks like;

macSerialNumber=$(system_profiler SPHardwareDataType | grep 'Serial Number (system)' | awk '{print $NF}')
loggedUser=$(ls -l /dev/console | awk '/ / { print $3 }')

echo "The Asset Management Script was ran on this machine, the Serial Number is $macSerialNumber and the Username is $loggedUser" | mailx -s "Asset Management $macSerialNumber | $loggedUser "  -c tes.test1@gmail.com -r test.test2@gmail.com  test.test3@gmail.com

I am writing the script in regular Mac OSX Catalina, any suggestions?

Jeff Holt
  • 2,940
  • 3
  • 22
  • 29
AkeeSF
  • 1
  • The `-r` option is not a macOS `mailx` option. What do you intend for `-r` to do on this OS? The linux version of `mailx` has such an option but it is for printing onto stdout. – Jeff Holt Feb 24 '20 at 20:28
  • @JeffHolt I am using the script to automate the Assest Mangement process for my team for the Mac machines. The script grabs the Serial Number and Current User and sends it to the emails I specify, all I'd like to do is change the From Address – AkeeSF Feb 24 '20 at 20:32
  • I think [this](https://stackoverflow.com/q/3317174/1707353) might be helpful. – Jeff Holt Feb 24 '20 at 20:32

0 Answers0