I
I
Ilya Trusov2016-02-22 21:37:18
bash
Ilya Trusov, 2016-02-22 21:37:18

How to write data to a file?

Hello. There is this script:

#!/bin/bash

code = $(echo -n '$4' | base64 -d)
cat <<EOF > /opt/jails/$1/home/$1/$2/$3
EOF

The $4 variable receives data encoded in base64. I decode, I try to write to a file, they are not recorded. PHP code is base64 encoded. I suspect it's a matter of shielding. I don’t understand how to escape, I don’t have enough knowledge in bash.
I will be grateful for help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Trusov, 2016-02-22
@artgrosvil

The problem was that the data was transferred from windows. But I still can't figure out the reason for the error. One of the solutions to the problem. (crutch)

echo $4 > /opt/jails/$1/home/$1/$2/$3.tmp

dos2unix < /opt/jails/$1/home/$1/$2/$3.tmp | base64 -d > /opt/jails/$1/home/$1/$2/$3

S
sim3x, 2016-02-22
@sim3x

#!/bin/bash
code = $(echo -n '$4' | base64 -d)
cat <<EOF > /opt/jails/$1/home/$1/$2/$3
$code
EOF
# or
echo $code > /opt/jails/$1/home/$1/$2/$3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question