SFTP download from terminal is fine, via script not working

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I am writing a backup script which will download all backups begins with hostname f.e MikroTik which is contained in variable device. When I put command in terminal it will download all files I need, but when I put it tot script, then it show me message file Mikrotik not found.



Here is the code sample:



#!/bin/bash
user="admin"
address="IP"
#command will get devcie hostname in complex form
ssh $user@$address '/system identity print interval=' > devices

#will get device hostname
tmpDevices=$(cat devices)

device=$(echo $tmpDevices | awk ' print $2 ')
echo "Device hostname is $device"

echo "Connecting to device via SFTP and downloading files"
#sftp "$user@$address:/$device*"
sftp $user@$address:$device*


Here is the output:



Device hostname is MikroTik
MikroTik
Connecting to device via SFTP and downloading files
Connected to 10.120.0.253.
File "/MikroTik" not found.


Can you please advice me.



Adrian.







share|improve this question




















  • What is /system? Does there exist a file/directory on 10.120.0.253 with a directory off root that starts with the hostname? The error File "/MikroTik" not found. seems self-explanatory.
    – Andy Dalton
    Dec 7 '17 at 15:13










  • It is on mikrotik so i tried with / or without and no success
    – Adrian Bardossy
    Dec 7 '17 at 15:18










  • That doesn't answer any of my questions. Do there exist files in the root directory on that host that begin with MikoTik?
    – Andy Dalton
    Dec 7 '17 at 15:20










  • yeah there is just root filesystem /
    – Adrian Bardossy
    Dec 7 '17 at 15:33










  • Please add the output of the following command to your question above: ssh $user@$address "ls /MikroTik*". Fill in user/address appropriately.
    – Andy Dalton
    Dec 7 '17 at 15:50














up vote
0
down vote

favorite












I am writing a backup script which will download all backups begins with hostname f.e MikroTik which is contained in variable device. When I put command in terminal it will download all files I need, but when I put it tot script, then it show me message file Mikrotik not found.



Here is the code sample:



#!/bin/bash
user="admin"
address="IP"
#command will get devcie hostname in complex form
ssh $user@$address '/system identity print interval=' > devices

#will get device hostname
tmpDevices=$(cat devices)

device=$(echo $tmpDevices | awk ' print $2 ')
echo "Device hostname is $device"

echo "Connecting to device via SFTP and downloading files"
#sftp "$user@$address:/$device*"
sftp $user@$address:$device*


Here is the output:



Device hostname is MikroTik
MikroTik
Connecting to device via SFTP and downloading files
Connected to 10.120.0.253.
File "/MikroTik" not found.


Can you please advice me.



Adrian.







share|improve this question




















  • What is /system? Does there exist a file/directory on 10.120.0.253 with a directory off root that starts with the hostname? The error File "/MikroTik" not found. seems self-explanatory.
    – Andy Dalton
    Dec 7 '17 at 15:13










  • It is on mikrotik so i tried with / or without and no success
    – Adrian Bardossy
    Dec 7 '17 at 15:18










  • That doesn't answer any of my questions. Do there exist files in the root directory on that host that begin with MikoTik?
    – Andy Dalton
    Dec 7 '17 at 15:20










  • yeah there is just root filesystem /
    – Adrian Bardossy
    Dec 7 '17 at 15:33










  • Please add the output of the following command to your question above: ssh $user@$address "ls /MikroTik*". Fill in user/address appropriately.
    – Andy Dalton
    Dec 7 '17 at 15:50












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am writing a backup script which will download all backups begins with hostname f.e MikroTik which is contained in variable device. When I put command in terminal it will download all files I need, but when I put it tot script, then it show me message file Mikrotik not found.



Here is the code sample:



#!/bin/bash
user="admin"
address="IP"
#command will get devcie hostname in complex form
ssh $user@$address '/system identity print interval=' > devices

#will get device hostname
tmpDevices=$(cat devices)

device=$(echo $tmpDevices | awk ' print $2 ')
echo "Device hostname is $device"

echo "Connecting to device via SFTP and downloading files"
#sftp "$user@$address:/$device*"
sftp $user@$address:$device*


Here is the output:



Device hostname is MikroTik
MikroTik
Connecting to device via SFTP and downloading files
Connected to 10.120.0.253.
File "/MikroTik" not found.


Can you please advice me.



Adrian.







share|improve this question












I am writing a backup script which will download all backups begins with hostname f.e MikroTik which is contained in variable device. When I put command in terminal it will download all files I need, but when I put it tot script, then it show me message file Mikrotik not found.



Here is the code sample:



#!/bin/bash
user="admin"
address="IP"
#command will get devcie hostname in complex form
ssh $user@$address '/system identity print interval=' > devices

#will get device hostname
tmpDevices=$(cat devices)

device=$(echo $tmpDevices | awk ' print $2 ')
echo "Device hostname is $device"

echo "Connecting to device via SFTP and downloading files"
#sftp "$user@$address:/$device*"
sftp $user@$address:$device*


Here is the output:



Device hostname is MikroTik
MikroTik
Connecting to device via SFTP and downloading files
Connected to 10.120.0.253.
File "/MikroTik" not found.


Can you please advice me.



Adrian.









share|improve this question











share|improve this question




share|improve this question










asked Dec 7 '17 at 15:10









Adrian Bardossy

23




23











  • What is /system? Does there exist a file/directory on 10.120.0.253 with a directory off root that starts with the hostname? The error File "/MikroTik" not found. seems self-explanatory.
    – Andy Dalton
    Dec 7 '17 at 15:13










  • It is on mikrotik so i tried with / or without and no success
    – Adrian Bardossy
    Dec 7 '17 at 15:18










  • That doesn't answer any of my questions. Do there exist files in the root directory on that host that begin with MikoTik?
    – Andy Dalton
    Dec 7 '17 at 15:20










  • yeah there is just root filesystem /
    – Adrian Bardossy
    Dec 7 '17 at 15:33










  • Please add the output of the following command to your question above: ssh $user@$address "ls /MikroTik*". Fill in user/address appropriately.
    – Andy Dalton
    Dec 7 '17 at 15:50
















  • What is /system? Does there exist a file/directory on 10.120.0.253 with a directory off root that starts with the hostname? The error File "/MikroTik" not found. seems self-explanatory.
    – Andy Dalton
    Dec 7 '17 at 15:13










  • It is on mikrotik so i tried with / or without and no success
    – Adrian Bardossy
    Dec 7 '17 at 15:18










  • That doesn't answer any of my questions. Do there exist files in the root directory on that host that begin with MikoTik?
    – Andy Dalton
    Dec 7 '17 at 15:20










  • yeah there is just root filesystem /
    – Adrian Bardossy
    Dec 7 '17 at 15:33










  • Please add the output of the following command to your question above: ssh $user@$address "ls /MikroTik*". Fill in user/address appropriately.
    – Andy Dalton
    Dec 7 '17 at 15:50















What is /system? Does there exist a file/directory on 10.120.0.253 with a directory off root that starts with the hostname? The error File "/MikroTik" not found. seems self-explanatory.
– Andy Dalton
Dec 7 '17 at 15:13




What is /system? Does there exist a file/directory on 10.120.0.253 with a directory off root that starts with the hostname? The error File "/MikroTik" not found. seems self-explanatory.
– Andy Dalton
Dec 7 '17 at 15:13












It is on mikrotik so i tried with / or without and no success
– Adrian Bardossy
Dec 7 '17 at 15:18




It is on mikrotik so i tried with / or without and no success
– Adrian Bardossy
Dec 7 '17 at 15:18












That doesn't answer any of my questions. Do there exist files in the root directory on that host that begin with MikoTik?
– Andy Dalton
Dec 7 '17 at 15:20




That doesn't answer any of my questions. Do there exist files in the root directory on that host that begin with MikoTik?
– Andy Dalton
Dec 7 '17 at 15:20












yeah there is just root filesystem /
– Adrian Bardossy
Dec 7 '17 at 15:33




yeah there is just root filesystem /
– Adrian Bardossy
Dec 7 '17 at 15:33












Please add the output of the following command to your question above: ssh $user@$address "ls /MikroTik*". Fill in user/address appropriately.
– Andy Dalton
Dec 7 '17 at 15:50




Please add the output of the following command to your question above: ssh $user@$address "ls /MikroTik*". Fill in user/address appropriately.
– Andy Dalton
Dec 7 '17 at 15:50










2 Answers
2






active

oldest

votes

















up vote
1
down vote













You might consider using scp instead of sftp. Assuming that you want to copy files from the root directory on the remote host to the current directory on the local host:



scp "$user@$address:/$device*" . 


For example, I've created the following files on a remote host:



$ ssh user@remoteHost "ls /MikroTik*"
/MikroTik_dec07backup.backup
/MikroTik_dec07export.rsc
/MikroTik_dec07log.txt


From my local host, I can do:



$ mkdir /tmp/example
$ cd /tmp/example
$ scp "user@remoteHost:/MikroTik*" .
MikroTik_dec07backup.backup 100% 0 0.0KB/s 00:00
MikroTik_dec07export.rsc 100% 0 0.0KB/s 00:00
MikroTik_dec07log.txt 100% 0 0.0KB/s 00:00
$ ls
MikroTik_dec07backup.backup MikroTik_dec07export.rsc MikroTik_dec07log.txt
$





share|improve this answer






















  • no success with that also, no file found but the files are there
    – Adrian Bardossy
    Dec 7 '17 at 15:37










  • Did you include the quotes as specified?
    – Andy Dalton
    Dec 7 '17 at 15:53










  • I was battling with this 4 hours yesterday nothing worked
    – Adrian Bardossy
    Dec 7 '17 at 15:54










  • Again, you didn't answer my question. When someone asks a question, that generally means that they need additional information in order to move forward.
    – Andy Dalton
    Dec 7 '17 at 15:56










  • yeah, i tried it as said, no file found also from terminal with proper parameters it was impossible to download them, no luck there mate
    – Adrian Bardossy
    Dec 7 '17 at 15:58


















up vote
-1
down vote













adrian@adrian-ThinkPad-X230:~/Desktop/zaloha$ sftp admin@IP:/MikroTik*
Connected to IP.
Fetching /MikroTik_dec07backup.backup to MikroTik_dec07backup.backup
/MikroTik_dec07backup.backup 100% 10KB 10.5KB/s 00:00
Fetching /MikroTik_dec07export.rsc to MikroTik_dec07export.rsc
/MikroTik_dec07export.rsc 100% 329 0.3KB/s 00:00
Fetching /MikroTik_dec07log.txt to MikroTik_dec07log.txt
/MikroTik_dec07log.txt 100% 75KB 75.1KB/s 00:00


When I use it ion script as :



#!/bin/bash
user="admin"
address="IP"
#command will get devcie hostname in complex form
ssh $user@$address '/system identity print interval=' > devices

#will get device hostname
tmpDevices=$(cat devices)

device=$(echo $tmpDevices | awk ' print $2 ')
echo "Device hostname is $device"

echo "Connecting to device via SFTP and downloading files"
#sftp "$user@$address:/$device*"
sftp $user@$address:$device*


Output is:



Connecting to device via SFTP and downloading files
Connected to address.
File "/MikroTik" not found.





share|improve this answer




















  • Not sure why you copied your question as an answer?
    – Andy Dalton
    Dec 7 '17 at 16:08










  • I think this should be an edit to your question...
    – Jeff Schaller
    Dec 7 '17 at 16:08










  • wanna help me or not? I am trying to get answers and your response is what I found on google guys and nothing helped
    – Adrian Bardossy
    Dec 7 '17 at 16:10










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f409497%2fsftp-download-from-terminal-is-fine-via-script-not-working%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













You might consider using scp instead of sftp. Assuming that you want to copy files from the root directory on the remote host to the current directory on the local host:



scp "$user@$address:/$device*" . 


For example, I've created the following files on a remote host:



$ ssh user@remoteHost "ls /MikroTik*"
/MikroTik_dec07backup.backup
/MikroTik_dec07export.rsc
/MikroTik_dec07log.txt


From my local host, I can do:



$ mkdir /tmp/example
$ cd /tmp/example
$ scp "user@remoteHost:/MikroTik*" .
MikroTik_dec07backup.backup 100% 0 0.0KB/s 00:00
MikroTik_dec07export.rsc 100% 0 0.0KB/s 00:00
MikroTik_dec07log.txt 100% 0 0.0KB/s 00:00
$ ls
MikroTik_dec07backup.backup MikroTik_dec07export.rsc MikroTik_dec07log.txt
$





share|improve this answer






















  • no success with that also, no file found but the files are there
    – Adrian Bardossy
    Dec 7 '17 at 15:37










  • Did you include the quotes as specified?
    – Andy Dalton
    Dec 7 '17 at 15:53










  • I was battling with this 4 hours yesterday nothing worked
    – Adrian Bardossy
    Dec 7 '17 at 15:54










  • Again, you didn't answer my question. When someone asks a question, that generally means that they need additional information in order to move forward.
    – Andy Dalton
    Dec 7 '17 at 15:56










  • yeah, i tried it as said, no file found also from terminal with proper parameters it was impossible to download them, no luck there mate
    – Adrian Bardossy
    Dec 7 '17 at 15:58















up vote
1
down vote













You might consider using scp instead of sftp. Assuming that you want to copy files from the root directory on the remote host to the current directory on the local host:



scp "$user@$address:/$device*" . 


For example, I've created the following files on a remote host:



$ ssh user@remoteHost "ls /MikroTik*"
/MikroTik_dec07backup.backup
/MikroTik_dec07export.rsc
/MikroTik_dec07log.txt


From my local host, I can do:



$ mkdir /tmp/example
$ cd /tmp/example
$ scp "user@remoteHost:/MikroTik*" .
MikroTik_dec07backup.backup 100% 0 0.0KB/s 00:00
MikroTik_dec07export.rsc 100% 0 0.0KB/s 00:00
MikroTik_dec07log.txt 100% 0 0.0KB/s 00:00
$ ls
MikroTik_dec07backup.backup MikroTik_dec07export.rsc MikroTik_dec07log.txt
$





share|improve this answer






















  • no success with that also, no file found but the files are there
    – Adrian Bardossy
    Dec 7 '17 at 15:37










  • Did you include the quotes as specified?
    – Andy Dalton
    Dec 7 '17 at 15:53










  • I was battling with this 4 hours yesterday nothing worked
    – Adrian Bardossy
    Dec 7 '17 at 15:54










  • Again, you didn't answer my question. When someone asks a question, that generally means that they need additional information in order to move forward.
    – Andy Dalton
    Dec 7 '17 at 15:56










  • yeah, i tried it as said, no file found also from terminal with proper parameters it was impossible to download them, no luck there mate
    – Adrian Bardossy
    Dec 7 '17 at 15:58













up vote
1
down vote










up vote
1
down vote









You might consider using scp instead of sftp. Assuming that you want to copy files from the root directory on the remote host to the current directory on the local host:



scp "$user@$address:/$device*" . 


For example, I've created the following files on a remote host:



$ ssh user@remoteHost "ls /MikroTik*"
/MikroTik_dec07backup.backup
/MikroTik_dec07export.rsc
/MikroTik_dec07log.txt


From my local host, I can do:



$ mkdir /tmp/example
$ cd /tmp/example
$ scp "user@remoteHost:/MikroTik*" .
MikroTik_dec07backup.backup 100% 0 0.0KB/s 00:00
MikroTik_dec07export.rsc 100% 0 0.0KB/s 00:00
MikroTik_dec07log.txt 100% 0 0.0KB/s 00:00
$ ls
MikroTik_dec07backup.backup MikroTik_dec07export.rsc MikroTik_dec07log.txt
$





share|improve this answer














You might consider using scp instead of sftp. Assuming that you want to copy files from the root directory on the remote host to the current directory on the local host:



scp "$user@$address:/$device*" . 


For example, I've created the following files on a remote host:



$ ssh user@remoteHost "ls /MikroTik*"
/MikroTik_dec07backup.backup
/MikroTik_dec07export.rsc
/MikroTik_dec07log.txt


From my local host, I can do:



$ mkdir /tmp/example
$ cd /tmp/example
$ scp "user@remoteHost:/MikroTik*" .
MikroTik_dec07backup.backup 100% 0 0.0KB/s 00:00
MikroTik_dec07export.rsc 100% 0 0.0KB/s 00:00
MikroTik_dec07log.txt 100% 0 0.0KB/s 00:00
$ ls
MikroTik_dec07backup.backup MikroTik_dec07export.rsc MikroTik_dec07log.txt
$






share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 7 '17 at 16:05

























answered Dec 7 '17 at 15:23









Andy Dalton

4,7841520




4,7841520











  • no success with that also, no file found but the files are there
    – Adrian Bardossy
    Dec 7 '17 at 15:37










  • Did you include the quotes as specified?
    – Andy Dalton
    Dec 7 '17 at 15:53










  • I was battling with this 4 hours yesterday nothing worked
    – Adrian Bardossy
    Dec 7 '17 at 15:54










  • Again, you didn't answer my question. When someone asks a question, that generally means that they need additional information in order to move forward.
    – Andy Dalton
    Dec 7 '17 at 15:56










  • yeah, i tried it as said, no file found also from terminal with proper parameters it was impossible to download them, no luck there mate
    – Adrian Bardossy
    Dec 7 '17 at 15:58

















  • no success with that also, no file found but the files are there
    – Adrian Bardossy
    Dec 7 '17 at 15:37










  • Did you include the quotes as specified?
    – Andy Dalton
    Dec 7 '17 at 15:53










  • I was battling with this 4 hours yesterday nothing worked
    – Adrian Bardossy
    Dec 7 '17 at 15:54










  • Again, you didn't answer my question. When someone asks a question, that generally means that they need additional information in order to move forward.
    – Andy Dalton
    Dec 7 '17 at 15:56










  • yeah, i tried it as said, no file found also from terminal with proper parameters it was impossible to download them, no luck there mate
    – Adrian Bardossy
    Dec 7 '17 at 15:58
















no success with that also, no file found but the files are there
– Adrian Bardossy
Dec 7 '17 at 15:37




no success with that also, no file found but the files are there
– Adrian Bardossy
Dec 7 '17 at 15:37












Did you include the quotes as specified?
– Andy Dalton
Dec 7 '17 at 15:53




Did you include the quotes as specified?
– Andy Dalton
Dec 7 '17 at 15:53












I was battling with this 4 hours yesterday nothing worked
– Adrian Bardossy
Dec 7 '17 at 15:54




I was battling with this 4 hours yesterday nothing worked
– Adrian Bardossy
Dec 7 '17 at 15:54












Again, you didn't answer my question. When someone asks a question, that generally means that they need additional information in order to move forward.
– Andy Dalton
Dec 7 '17 at 15:56




Again, you didn't answer my question. When someone asks a question, that generally means that they need additional information in order to move forward.
– Andy Dalton
Dec 7 '17 at 15:56












yeah, i tried it as said, no file found also from terminal with proper parameters it was impossible to download them, no luck there mate
– Adrian Bardossy
Dec 7 '17 at 15:58





yeah, i tried it as said, no file found also from terminal with proper parameters it was impossible to download them, no luck there mate
– Adrian Bardossy
Dec 7 '17 at 15:58













up vote
-1
down vote













adrian@adrian-ThinkPad-X230:~/Desktop/zaloha$ sftp admin@IP:/MikroTik*
Connected to IP.
Fetching /MikroTik_dec07backup.backup to MikroTik_dec07backup.backup
/MikroTik_dec07backup.backup 100% 10KB 10.5KB/s 00:00
Fetching /MikroTik_dec07export.rsc to MikroTik_dec07export.rsc
/MikroTik_dec07export.rsc 100% 329 0.3KB/s 00:00
Fetching /MikroTik_dec07log.txt to MikroTik_dec07log.txt
/MikroTik_dec07log.txt 100% 75KB 75.1KB/s 00:00


When I use it ion script as :



#!/bin/bash
user="admin"
address="IP"
#command will get devcie hostname in complex form
ssh $user@$address '/system identity print interval=' > devices

#will get device hostname
tmpDevices=$(cat devices)

device=$(echo $tmpDevices | awk ' print $2 ')
echo "Device hostname is $device"

echo "Connecting to device via SFTP and downloading files"
#sftp "$user@$address:/$device*"
sftp $user@$address:$device*


Output is:



Connecting to device via SFTP and downloading files
Connected to address.
File "/MikroTik" not found.





share|improve this answer




















  • Not sure why you copied your question as an answer?
    – Andy Dalton
    Dec 7 '17 at 16:08










  • I think this should be an edit to your question...
    – Jeff Schaller
    Dec 7 '17 at 16:08










  • wanna help me or not? I am trying to get answers and your response is what I found on google guys and nothing helped
    – Adrian Bardossy
    Dec 7 '17 at 16:10














up vote
-1
down vote













adrian@adrian-ThinkPad-X230:~/Desktop/zaloha$ sftp admin@IP:/MikroTik*
Connected to IP.
Fetching /MikroTik_dec07backup.backup to MikroTik_dec07backup.backup
/MikroTik_dec07backup.backup 100% 10KB 10.5KB/s 00:00
Fetching /MikroTik_dec07export.rsc to MikroTik_dec07export.rsc
/MikroTik_dec07export.rsc 100% 329 0.3KB/s 00:00
Fetching /MikroTik_dec07log.txt to MikroTik_dec07log.txt
/MikroTik_dec07log.txt 100% 75KB 75.1KB/s 00:00


When I use it ion script as :



#!/bin/bash
user="admin"
address="IP"
#command will get devcie hostname in complex form
ssh $user@$address '/system identity print interval=' > devices

#will get device hostname
tmpDevices=$(cat devices)

device=$(echo $tmpDevices | awk ' print $2 ')
echo "Device hostname is $device"

echo "Connecting to device via SFTP and downloading files"
#sftp "$user@$address:/$device*"
sftp $user@$address:$device*


Output is:



Connecting to device via SFTP and downloading files
Connected to address.
File "/MikroTik" not found.





share|improve this answer




















  • Not sure why you copied your question as an answer?
    – Andy Dalton
    Dec 7 '17 at 16:08










  • I think this should be an edit to your question...
    – Jeff Schaller
    Dec 7 '17 at 16:08










  • wanna help me or not? I am trying to get answers and your response is what I found on google guys and nothing helped
    – Adrian Bardossy
    Dec 7 '17 at 16:10












up vote
-1
down vote










up vote
-1
down vote









adrian@adrian-ThinkPad-X230:~/Desktop/zaloha$ sftp admin@IP:/MikroTik*
Connected to IP.
Fetching /MikroTik_dec07backup.backup to MikroTik_dec07backup.backup
/MikroTik_dec07backup.backup 100% 10KB 10.5KB/s 00:00
Fetching /MikroTik_dec07export.rsc to MikroTik_dec07export.rsc
/MikroTik_dec07export.rsc 100% 329 0.3KB/s 00:00
Fetching /MikroTik_dec07log.txt to MikroTik_dec07log.txt
/MikroTik_dec07log.txt 100% 75KB 75.1KB/s 00:00


When I use it ion script as :



#!/bin/bash
user="admin"
address="IP"
#command will get devcie hostname in complex form
ssh $user@$address '/system identity print interval=' > devices

#will get device hostname
tmpDevices=$(cat devices)

device=$(echo $tmpDevices | awk ' print $2 ')
echo "Device hostname is $device"

echo "Connecting to device via SFTP and downloading files"
#sftp "$user@$address:/$device*"
sftp $user@$address:$device*


Output is:



Connecting to device via SFTP and downloading files
Connected to address.
File "/MikroTik" not found.





share|improve this answer












adrian@adrian-ThinkPad-X230:~/Desktop/zaloha$ sftp admin@IP:/MikroTik*
Connected to IP.
Fetching /MikroTik_dec07backup.backup to MikroTik_dec07backup.backup
/MikroTik_dec07backup.backup 100% 10KB 10.5KB/s 00:00
Fetching /MikroTik_dec07export.rsc to MikroTik_dec07export.rsc
/MikroTik_dec07export.rsc 100% 329 0.3KB/s 00:00
Fetching /MikroTik_dec07log.txt to MikroTik_dec07log.txt
/MikroTik_dec07log.txt 100% 75KB 75.1KB/s 00:00


When I use it ion script as :



#!/bin/bash
user="admin"
address="IP"
#command will get devcie hostname in complex form
ssh $user@$address '/system identity print interval=' > devices

#will get device hostname
tmpDevices=$(cat devices)

device=$(echo $tmpDevices | awk ' print $2 ')
echo "Device hostname is $device"

echo "Connecting to device via SFTP and downloading files"
#sftp "$user@$address:/$device*"
sftp $user@$address:$device*


Output is:



Connecting to device via SFTP and downloading files
Connected to address.
File "/MikroTik" not found.






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 7 '17 at 16:05









Adrian Bardossy

23




23











  • Not sure why you copied your question as an answer?
    – Andy Dalton
    Dec 7 '17 at 16:08










  • I think this should be an edit to your question...
    – Jeff Schaller
    Dec 7 '17 at 16:08










  • wanna help me or not? I am trying to get answers and your response is what I found on google guys and nothing helped
    – Adrian Bardossy
    Dec 7 '17 at 16:10
















  • Not sure why you copied your question as an answer?
    – Andy Dalton
    Dec 7 '17 at 16:08










  • I think this should be an edit to your question...
    – Jeff Schaller
    Dec 7 '17 at 16:08










  • wanna help me or not? I am trying to get answers and your response is what I found on google guys and nothing helped
    – Adrian Bardossy
    Dec 7 '17 at 16:10















Not sure why you copied your question as an answer?
– Andy Dalton
Dec 7 '17 at 16:08




Not sure why you copied your question as an answer?
– Andy Dalton
Dec 7 '17 at 16:08












I think this should be an edit to your question...
– Jeff Schaller
Dec 7 '17 at 16:08




I think this should be an edit to your question...
– Jeff Schaller
Dec 7 '17 at 16:08












wanna help me or not? I am trying to get answers and your response is what I found on google guys and nothing helped
– Adrian Bardossy
Dec 7 '17 at 16:10




wanna help me or not? I am trying to get answers and your response is what I found on google guys and nothing helped
– Adrian Bardossy
Dec 7 '17 at 16:10

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f409497%2fsftp-download-from-terminal-is-fine-via-script-not-working%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)