Bash script needs to e-mail output
Hello friend, last one week, I work on the bash Linux operating system. This OS is one of the type of the UNIX operating system. Yesterday, I work on a new backup script. This script puts the specific output. I want to email this script output. Actually I want some technique or code which helps to email this output to the previously set email address. The same kind of operations performs by the cron job. Can I do this? If anyone having knowledge about it then please share it. Any help will be appreciates.
Re: Bash script needs to e-mail output
There are no direct connections present in this bash script and the email. You need to first save the output to the backup utility such as files. Then send this file to the specific email address. This can be done by adding the code of both operations into the single script. This will helps to solve the trouble. This is indirect solutions of the trouble. I will explain just the overview of the solutions. You need to build that code. Then it helps you to solve the trouble.
Re: Bash script needs to e-mail output
Hey, I have done this kind of code. I will tel you that code instructions. First copy the output to one file. For doing this use the tar command. Then it helps to copy the output the file. Then use the sendmail command for sending the output to the other person. You can also use the other command mail -s and then put the file name for sending the mail. This is the best way to send the output file to the specific email address. Then use it and send mail of the script output.
Re: Bash script needs to e-mail output
There is no need to doing such kind of effort. There are already presents some kind of code. This code help to perform the operations. I tell you the code. Just use the pipe command of the bash Linux OS and this is so helpful to perform such kind of operations in the single line. In the prompt enter the bash script file execute command. Then insert the pipe symbol. Then immediately use the tee command the put the output to the text file. Then after that insert pipe symbol and enter the mail command. Finally just execute this single line code. This code will execute fast. Then in single line the script is executed, output is generated and then it sends to the email address.
Re: Bash script needs to e-mail output
If you want to perform these operations again and again then I suggest you to design the stored procedure code. The procedure concept is specially designed for performing this kind of complex operations reputedly. You need to define the procedure and in that procedure mention this four line code. Then store it into the system directory. It helps you to execute the code again and again. This will helps to solve the trouble.