0

I want to run an ssh command to get the path on a remote machine in order to get the last file and store it into a variable. This is what I've made so far:

#!/bin/bash
database="devdatabase";
echo "Executing Restore Database: '$database'"
filetodump=ssh user@myvirtualmysqlmachine.com 'bash -s'$(ls -1t -d /var/MySQLBackups/prod_mysql/* | grep dump | head -n 1)
echo "This is to test that the srcipt works: '$filetodump'"

How can i get the $filetodump variable?

Kristian
  • 21
  • 2
  • Not really since in that situation the command is not run over ssh. I'm running an SSH in order to get a path then display this path with echo – Kristian Jul 23 '20 at 08:18
  • What's the difference? `ssh` is still a command. And its output can be capture to a variable in the same way. Have you tried it? – kaylum Jul 23 '20 at 08:30
  • If we want to have the result of a command, we must put the command between $ (cmd) or `cmd` – mchelabi Jul 23 '20 at 08:32

0 Answers0