LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-15-2020, 05:29 AM   #1
hvc123
Member
 
Registered: Jun 2004
Posts: 33

Rep: Reputation: 16
SCP mutliple hosts with same filename


HI all

can anyone help with the scp variables or maybe even a bash script ?

im trying to scp to multiple cisco devices and pull their running-config i then need to output them to the host name rather than just running-config as the file name.

i thought there maybe a wildcard for host name is available but i cant see it..

thanks
 
Old 06-15-2020, 08:31 AM   #2
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Quote:
Originally Posted by hvc123 View Post
i thought there maybe a wildcard for host name is available but i cant see it..
scp conforms to the cp syntax, so it has got only a single "destination", after optionally expanding wildcards: the last argument in the resulting commandline.
So you would need either multiple scp lines, just varying the destination host/path or maybe this is better suited to a program like rdist:
Quote:
Rdist is a program to maintain identical copies of files over multiple hosts. It preserves the owner, group, mode, and mtime of files if possible and can update programs that are executing. Rdist reads commands from distfile to direct the updating of files and/or directories.
 
Old 06-15-2020, 08:59 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,875

Rep: Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890
Do you mean something like this?
Code:
for a_host in ${HOSTNAME_LIST[@]}
do
    scp whatever $a_host
done
 
Old 06-15-2020, 09:27 AM   #4
hvc123
Member
 
Registered: Jun 2004
Posts: 33

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by pan64 View Post
Do you mean something like this?
Code:
for a_host in ${HOSTNAME_LIST[@]}
do
    scp whatever $a_host
done
yes definitely something like this ,,, Thank you

whats the [@] for ?
 
Old 06-15-2020, 09:40 AM   #5
berndbausch
LQ Guru
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 5,020

Rep: Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504Reputation: 1504
Quote:
Originally Posted by hvc123 View Post
im trying to scp to multiple cisco devices and pull their running-config i then need to output them to the host name rather than just running-config as the file name.

i thought there maybe a wildcard for host name is available but i cant see it..
You want to copy the running-config (whatever that is) from multiple cisco devices. What do you mean by host name? The names of the devices? If so:
Code:
for NAME in name1 name2 name3 ....
do
    scp account@$NAME:running-config $NAME
done
Your mission, should you decide to accept it: Replace "name1 name2 name3 ..." with the actual names, fix the source of the scp command, because I have no idea where running-config might be located, and replace "account" with the correct user account.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mutliple CLI? malak33 Linux - Newbie 9 12-10-2011 05:43 PM
Compression/archive tool that utilizes mutliple cores? hawk__0 Linux - Software 3 10-01-2009 11:13 PM
Mutliple Drive booting.. saif_shakeel Linux - Distributions 4 09-03-2008 01:09 AM
RS232 serial port errors when performing mutliple writes riffy Linux - Newbie 0 07-11-2006 12:12 PM
mutliple email addresses (domains) lenlutz Linux - Networking 2 10-15-2003 06:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration