2017-01-31 5 views
1

전자 메일로 여러 파일을 보내려고하지만 전자 메일에 본문 메시지를 포함하려고합니다. 몇 가지 방법을 시도했습니다. 운은, 다음 코드는 전송 여러 파일입니다 :전자 메일로 여러 파일 보내기 및 전자 메일에 본문 메시지 추가 (Unix Korn Shell)

echo "This is the body message" | (uuencode file1.txt file1.txt ; uuencode file2.txt file2.txt) | mailx -s "test" [email protected]

어떤 생각이 어떻게 코드 수 :

(uuencode file1.txt file1.txt ; uuencode file2.txt file2.txt) | mailx -s "test" [email protected]

내가 운이 옵션을 시도했습니다?

답변

1

이 시도 :

(echo "This is the body message"; uuencode file1.txt file1.txt; uuencode file2.txt file2.txt) | mailx -s "test" [email protected] 

명령과 함께 문제는 당신이 서브 쉘에 echo의 출력을 파이프하고이 표준 입력에서 읽기되지 uuencode 무시지고 있다는 점이다.

당신은 서브 쉘 피하기 위해 { ... }를 사용할 수 있습니다

{ echo "This is the body message"; uuencode file1.txt file1.txt; uuencode file2.txt file2.txt; } | mailx -s "test" [email protected] 

스크립트에서이 일을하는 경우와 당신이 그것을 더 읽기보고 싶다, 다음 :

{ 
    echo "This is the body message" 
    uuencode file1.txt file1.txt 
    uuencode file2.txt file2.txt 
} | mailx -s "test" [email protected] 
+1

최고입니다! 매력으로 일하고! –