Reputation: 25
I'm trying to run bash script written in here: Link
I fixed script above like this:
#!/bin/bash
keyFile=video.key
openssl rand 16 > $keyFile
encryptionKey=cat $keyFile | hexdump -e '16/1 "%02x"'
splitFilePrefix=stream
encryptedSplitFilePrefix=enc/${splitFilePrefix}
numberOfTsFiles=ls ${splitFilePrefix}*.ts | wc -l
for (( i=1; i<$numberOfTsFiles; i++ ))
do
initializationVector=printf '%032x' $i
openssl aes-128-cbc -e -in ${splitFilePrefix}$i.ts -out ${encryptedSplitFilePrefix}$i.ts -nosalt -iv $initializationVector -K $encryptionKey
ran script like this: ./script.sh
but bash keeps yelling like this:
./script.sh: line 5: video.key: command not found
./script.sh: line 10: stream0.ts: command not found
0
./script.sh: line 17: syntax error: unexpected end of file
I have no idea why..
I searched about the error and checked ~/.rnd owner
, .sh file chmod +x
, $PATH
problems, but all of them did not work.
Upvotes: 0
Views: 1232
Reputation: 97948
This line:
encryptionKey=cat $keyFile | hexdump -e '16/1 "%02x"'
is trying to execute cat
, but you are not using command substitution. It should be:
encryptionKey=$(cat "$keyFile" | hexdump -e '16/1 "%02x"')
similarly, you need:
numberOfTsFiles=$(ls ${splitFilePrefix}*.ts | wc -l)
and need a done after the loop:
for (( i=1; i<$numberOfTsFiles; i++ ))
do
# ...
done
Upvotes: 2