0

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.

1
  • You are missing some characters in your script, in the original, line 5 is for example like this: keyFile=”video.key”, line 10: should be like this: splitFilePrefix=”stream” etc. Pls check the original script again Commented Aug 20, 2014 at 7:32

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.