如何编写一个shell脚本,从特定路径中选择excel工作表并将其作为附件发送?

如何编写一个shell脚本,从特定路径中选择excel工作表并将其作为附件发送?,shell,unix,Shell,Unix,在下面的例子中,我收到的是邮件,但不是附件。 我已经尝试了以下脚本 #!/bin/ksh path ="users/Modeling/Analyst\ Folder/Piped" echo "After path: $path" cd $path file =`ls -lrt | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 2,3` echo "File name found" uuencode '$path/file' 'file'| mai

在下面的例子中,我收到的是邮件,但不是附件。 我已经尝试了以下脚本

#!/bin/ksh

path ="users/Modeling/Analyst\ Folder/Piped"

echo "After path: $path"

cd $path

file =`ls -lrt | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 2,3`

echo "File name found"

uuencode '$path/file' 'file'| mailx -s 'file' 'Billa21@outlook.com'

echo "File attached and mailed"
但这不起作用

我得到的输出是:

pipeline.sh: path: not found
After path:
=:              cannot open: No such file or directory
dead.letter:    ascii text
File name found
$path/file: No such file or directory
File attached and mailed
但是如果我单独运行命令。。。
我正在获得所需的结果。

请尝试使用mailx和-a选项将文件作为附件发送到邮件中。

请尝试使用mailx和-a选项将文件作为附件发送到邮件中。

错误消息非常清楚地表明,这与发送附件没有任何关系。你可以把
mailx
从你的问题中抽象出来

(不过,作为旁白,-您使用的
mailx
是错误的;请阅读文档。)

问题是您没有正确设置变量
path
;解释器对
=
的混淆表明您有语法错误,消息
$path/file:No-this file或directory
表明
$path
在脚本中的该点上没有任何计算结果

  path ="users/Modeling/Analyst\ Folder/Piped"
#     ^
去掉多余的空间


请更加小心,不要在键入时添加随机字符。

错误消息清楚地表明,这与邮寄附件无关。你可以把
mailx
从你的问题中抽象出来

(不过,作为旁白,-您使用的
mailx
是错误的;请阅读文档。)

问题是您没有正确设置变量
path
;解释器对
=
的混淆表明您有语法错误,消息
$path/file:No-this file或directory
表明
$path
在脚本中的该点上没有任何计算结果

  path ="users/Modeling/Analyst\ Folder/Piped"
#     ^
去掉多余的空间

在你打字时要格外小心,不要随意添加字符