1

I need to create a script which receives from the CLI the name of a file with the extension .tar.gz and a folder(e.g ./archivator.sh box.tar.gz MyFolder). This script will archive the files from the folder(only the files WITHIN the folder and without any compression) and they will be moved into the archive received as a parameter. The archive will be then encrypted(using the aescrypt) with the password 'apple'.

OS: Debian 6

Note: The final encrypted archive will have the same name as the first given parameter.

What i have tried so far is this:

tar -cvf $1 $2/* | aescrypt -e -p apple - > $1.aes | mv $1.aes $1

And this is what I receive when I am trying to check my script:

tar: This does not look like a tar archive
tar: Exiting with a failure status due to previous errors
4

3 回答 3

1

尝试这样做:

tar cf - $2/* | aescrypt -e -p apple - > $1

-在这里,表示STDIN

使用 GNU tar 1.26 在 Linux (archlinux) 上运行良好

如果它不起作用,请在调试模式下运行脚本:

bash -x script.sh

然后再来张贴输出。

于 2012-12-01T16:13:04.597 回答
1

经过一番研究,这里是解决方案:

pushd $2
tar cvf $1 .
openssl aes-256-cbc -in $1 -out $1.enc -pass pass:apple
mv $1.enc $1
popd
于 2012-12-16T13:41:07.883 回答
0

您的错误似乎表明解释器正在接收一个不是 tar 存档的文件,但它需要一个。您是否检查过以确保您提供的文件是 tar 存档?

于 2012-12-01T16:53:54.317 回答