K
K
Konstantin Bozhkov2019-01-22 20:18:56
bash
Konstantin Bozhkov, 2019-01-22 20:18:56

How to unzip a file on a remote server?

I am writing a script that sends an archive with databases to the server, and unpacks it there. But I can not correctly write the unpacking.

tar -zcvf ./$fileName $dbsDir
scp ./$fileName [email protected]$server:/home

# Не работает. Просто пример
ssh [email protected]$server 'cd /home && tar xvf $fileName'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Bozhkov, 2019-01-22
@ybiks

Both implementations work:

ssh [email protected]$server << ENDSSH
cd /home && tar xvf $fileName
ENDSSH

ssh [email protected]$server << ENDSSH
tar xvf /home/$fileName -C /home
ENDSSH

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question