0

I am having problems using a program called 'ccrypt' which is used to encrypt files. The way in which I am using it is as follows:

ccrypt -e -E $cryptograph `find . -type f | sed -n -e '$i{p;q}'`

where -e means that the program is running in encrypt mode. My problem is as follows:

The manual for the command says that -E is used to read the passphrase for the encryption from an environment variable using this syntax:

-E var

and as such I have set it to be the passphrase I want as below:

cryptograph="Example_passphrase"

However, when I run the code as shown above, an error message appears as follows:

ccrypt: environment variable Example_passphrase does not exist.

Does anybody have any idea what I am doing wrong?

EDIT: Thanks for the answers, exporting the variable and removing the "$" worked but now I face a new problem:

"sed -n -e '$i{p;q}'"

The shell says:

ccrypt: {p;q}: No such file or directory

However, if I exchange $i for a number then the program works to an extent. What is the correct syntax for using the variable 'i' here?

4

2 回答 2

2

不要忘记导出环境变量(直到导出,它只是一个变量,而不是环境变量)。

export cryptograph="Example_passphrase"
ccrypt -e -E cryptograph `find . -type f | sed -n -e '$i{p;q}'`

仅指定名称至关重要(否$)。否则,变量的值——密码本身——在命令行参数中并且对ps等可见。我们可以讨论环境是否安全(想想/proc文件系统),但它比包含密码本身要好几个步骤在命令行上。


从评论看来,您最好执行以下操作:

find . -type f -exec ccrypt -e -E cryptograph {} ';'

这样做的一个主要优点是它回避了文件名中的空格和其他奇数字符的所有问题。如果该ccrypt命令接受多个文件,您可能可以将引号替换为';'+不需要引号),并且单个命令将加密所有文件。

于 2012-07-23T22:06:30.973 回答
1

Just use the name of the variable as the argument, not its value:

ccrypt -e -E cryptograph `...`
于 2012-07-23T21:51:14.117 回答