pbxuser911 Posted October 12, 2009 Report Share Posted October 12, 2009 I have a script that will show me all DID's and to which domain its on #!/bin/bash # Show all account names that are a telephone number: function get_xml() { gawk -v tag=$1 'BEGIN{regex="<" tag ">([^<]*)</" tag ">";}{ match($0, regex, m); for(i = 1;; i++) { if(!(i in m))\ break; printf("%s\n",m[i]);}}' $2 } for alias in user_alias/*.xml do name=${alias:11} # only the name idx=${name%.xml} # only the number name=$(get_xml name $alias) if [ -z "$name" -o "${#name}" -lt 8 ]; then continue; fi user=$(get_xml user $alias) domain=$(get_xml domain $alias) domainname=$(get_xml name domains/$domain.xml) echo $name $domainname done any Linux Gurus on here can tell me how to modify it and have it send me the results in a email? Quote Link to comment Share on other sites More sharing options...
Vodia PBX Posted October 12, 2009 Report Share Posted October 12, 2009 I guess you need to send it to mail: http://linux.die.net/man/1/mail. You can either use a pipe (|) or first redirect the result into a file and then send it with mail. Though I am not a Linux guru Quote Link to comment Share on other sites More sharing options...
pbxuser911 Posted October 12, 2009 Author Report Share Posted October 12, 2009 can anyone modify the above codes and make it put the results in a file that will be overwritten every time the command is used, and then the file will be emailed? Quote Link to comment Share on other sites More sharing options...
olecoot Posted October 14, 2009 Report Share Posted October 14, 2009 You can have the script write the information to a file. Then use this little program to have it emailed to you. Open source email program I've used this program for quite some time without any issues at all. It just works! Quote Link to comment Share on other sites More sharing options...
pbxuser911 Posted October 14, 2009 Author Report Share Posted October 14, 2009 what I did now was make another script that runs the first scripts and outputs it into a file which the results of the file get sent in a email thanks so much here is the code I used #!/bin/bash date=`date "+%m%d%y_%H%M"` filename=/usr/local/pbx/pbx_did.txt ./show_did.sh > $filename echo | mailx -s "subject line" emaito@mail.com-- -r emailfrom@mail.com < $filename does anyone know how would I change the display name of what email address the email is going to come from? now it just shows emailfrom@mail.com, I want it to say Email From and if I hit reply it will go to emailfrom@mail.com Quote Link to comment Share on other sites More sharing options...
pbxuser911 Posted October 19, 2009 Author Report Share Posted October 19, 2009 bump Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.