2013-11-21 7 views
6

मैं एक बैश स्क्रिप्ट बनाने की कोशिश कर रहा हूं जो सभी संपर्कों को एक ईमेल भेजेगा जिसमें एक संदेश और अनुलग्नक होगा। यह दुर्भावनापूर्ण उद्देश्यों के लिए नहीं है।मैक टर्मिनल अनुलग्नक के साथ ईमेल भेज रहा है

मैं यह कैसे कर सकता हूं? क्या यह संभव है? अग्रिम में धन्यवाद।

+0

कहाँ हो " सभी संपर्क "आपके लिए संग्रहीत? क्या यह आपके पता पुस्तिका आवेदन में संपर्क है? क्या आपने इसके लिए सेब स्क्रिप्ट का उपयोग करने पर विचार किया है? – Floris

उत्तर

9

मैं पहले uuencode का इस्तेमाल किया है यह पूरा करने के:

uuencode source.txt destination.txt | mail -s "subject of mail" [email protected] 

आप अपने bash लिपि में इस का उपयोग कर सकते हैं। नमूना:

uuencode /usr/bin/xxx.c MyFile.c | mail -s "mailing my c file" [email protected] 

http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds5/uuencode.htm

+0

मैं file.txt को किस स्थान से बदलूं? ~/Path/to/file.txt? दो क्यों हैं? –

+0

संक्षिप्त उत्तर के लिए खेद है ... uuencode के लिए पहला तर्क स्रोत है और दूसरा तर्क गंतव्य फ़ाइल नाम है .... इसलिए यदि आप ऐसा करते हैं: uuencode source.txt destination.txt | मेल-एस "विषय" [email protected] यह आपके system.txt को स्थानीय सिस्टम से आपके ईमेल आईडी पर नाम फ़ाइल.txt – Kush

+0

धन्यवाद के साथ भेज देगा। इसके अलावा, मैं इसे कैसे बनाऊंगा ताकि यह मेरी संपर्क सूची में सभी को ईमेल भेज सके? –

1

तुम भी उपयोग कर सकते हैं AppleScript:

tell application "Mail" 
    tell (make new outgoing message) 
     set subject to "subject" 
     set content to "content" 
     -- set visible to true 
     make new to recipient at end of to recipients with properties {address:"[email protected]", name:"Name"} 
     make new attachment with properties {file name:(POSIX file "/tmp/test.txt")} at after the last paragraph 
     send 
    end tell 
end tell 

आप एक खोल से तर्क पारित करने के लिए एक स्पष्ट रन हैंडलर का उपयोग कर सकते हैं:

osascript -e 'on run {a} 
    set text item delimiters to ";" 
    repeat with l in paragraphs of a 
     set {contact, address} to text items of l 
    end repeat 
end run' "Name1;[email protected] 
Name2;[email protected]" 
संबंधित मुद्दे