以下工作將會將/tmp/file.docx
轉換爲/tmp/file.pdf
。使用命令行重定向輸入和輸出
libreoffice3.5. --headless --convert-to pdf --outdir /tmp /tmp/file.docx
我將如何轉換https://www.mysite.com/getfile.php?id=123(這將返回一個的docx文件),並將其保存爲/tmp/file_123.pdf
?我期望它需要wget,管道和輸入/輸出重定向。
謝謝
編輯 - 響應zebediah49的帖子
> libreoffice3.5 --headless --convert-to pdf --outdir /tmp <(wget -O - "http://www.mysite.com/demo/lib/m.php?cid=9&controller=detail&task=displayDocument&id=56&x=fc872c033770e3bc8706e6a90bcdff02")
--2012-07-03 14:09:03-- http://www.mysite.com/demo/lib/m.php?cid=9&controller=detail&task=displayDocument&id=56&x=fc872c033770e3bc8706e6a90bcdff02
Resolving www.mysite.com... 99.999.999.999
Connecting to www.mysite.com|99.999.999.999|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 29696 (29K) [application/msword]
Saving to: `STDOUT'
0K .......... .......... ......... 100% 14.2M=0.002s
2012-07-03 14:09:03 (14.2 MB/s) - `-' saved [29696/29696]
編輯 - 響應rekire的第一個解決方案
> wget http://www.mysite.com/demo/lib/m.php?cid=9&controller=detail&task=displayDocument&id=56&x=fc872c033770e3bc8706e6a90bcdff02 --no-check-certificate -O /tmp/file.docx
--2012-07-03 14:34:12-- http://www.mysite.com/demo/lib/m.php?cid=9
Resolving www.mysite.com... bash: --no-check-certificate: command not found
99.999.999.999
Connecting to www.mysite.com|99.999.999.999|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1236 (1.2K) [text/html]
Saving to: `m.php?cid=9.8'
0K . 100% 42.1M=0s
2012-07-03 14:34:12 (42.1 MB/s) - `m.php?cid=9.8' saved [1236/1236]
> libreoffice3.5 --headless --convert-to pdf --outdir /tmp /tmp/file.docx
編輯 - 響應rekire的第二個解決方案
> TMPFILE=`mktemp -u`
> wget http://www.mysite.com/demo/lib/m.php?cid=9&controller=detail&task=displayDocument&id=56&x=fc872c033770e3bc8706e6a90bcdff02 --no-check-certificate -O $TMPFILE
--2012-07-03 14:24:09-- http://www.mysite.com/demo/lib/m.php?cid=9
Resolving www.mysite.com... bash: --no-check-certificate: command not found
99.999.999.999
Connecting to www.mysite.com|99.999.999.999|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1236 (1.2K) [text/html]
Saving to: `m.php?cid=9.5'
0K . 100% 42.1M=0s
2012-07-03 14:24:09 (42.1 MB/s) - `m.php?cid=9.5' saved [1236/1236]
> libreoffice3.5 --headless --convert-to pdf --outdir /tmp $TMPFILE
我想補充說一個人應該使用'mktemp'來避免意外 – zebediah49
@ zebediah49不錯的提示我還不知道那個命令 – rekire
謝謝rekire,TTesting我們說話。不意味着顯示爲https。只要擺脫「 - 無檢查證書」? – user1032531