This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
有 多种不同的
mailx
实现,因此具体的工作方式取决于您安装的版本。但是,作为一种快速而肮脏的解决方法,您可以暂时
cd
进入该目录(前提是您具有对该目录的执行访问权限):括号在子 shell 中运行命令,以便
的效果cd
只会影响该子 shell,程序的其余部分可以像以前一样继续进行。如果您的
mailx
实现放入Content-Disposition:
并在文件名中包含文件的完整路径,我会将其视为错误。另一种方法是使用不同的客户端。如果您无法安装例如
mutt
,请创建一个简单的 shell 脚本包装器来围绕base64
或quoted-printable
编码构建 MIME 结构你的 CSV 文件并不是特别难,但你必须知道你在做什么。简而言之,显然您必须安装
base64
和sendmail
,并且可能会调整sendmail
的路径(或者如果是的话则忽略它)在您的PATH
中)。There are multiple different
mailx
implementations around, so what exactly works will depend on the version you have installed.However, as a quick and dirty workaround, you can temporarily
cd
into that directory (provided you have execute access to it):The parentheses run the command in a subshell so that the effect of the
cd
will only affect that subshell, and the rest of your program can proceed as before.I would regard it as a bug if your
mailx
implementation puts in aContent-Disposition:
with the full path of the file in the filename.An alternative approach would be to use a different client. If you can't install e.g.
mutt
, creating a simple shell script wrapper to build the MIME structure around abase64
orquoted-printable
encoding of your CSV file is not particularly hard, but you have to know what you are doing. In very brief,where obviously you have to have
base64
andsendmail
installed, and probably tweak the path tosendmail
(or just omit it if it's in yourPATH
).