LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-08-2016, 01:52 AM   #1
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 64

Rep: Reputation: Disabled
Lightbulb Alias not working with for loop?


Hi Guys,
I tried to copy the zip file from localhost to two remote machine, I aliased my remote hostsnames.
Hence i use the for loop like this

Code:
 for g in hy1 hy2;do scp kube.tar.gz $g:~;done
hy1,hy2- alias for remote hostnames

when i ran this command, It returns the following error

Quote:
ssh: Could not resolve hostname hy1: Name or service not known
lost connection
ssh: Could not resolve hostname hy2: Name or service not known
lost connection
Its there any problem with using alias for file sharing, with loop
 
Old 12-08-2016, 02:14 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
no, alias does not work inside commands, just at the beginning of the line.
you may try to use ~/.ssh/config to set up such aliases especially for ssh, or you can use variables:
Code:
hy1="my1.host.name"
hy2="my2.host.name"
for g in hy1 hy2;do scp kube.tar.gz ${!g}:~;done
(not tested)

Last edited by pan64; 12-08-2016 at 02:15 AM. Reason: typo
 
1 members found this post helpful.
  


Reply

Tags
alias, for loop, scp



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
alias not working after su? galtolq Linux - Newbie 4 04-20-2016 01:27 AM
[SOLVED] sendmail alias not working RagingRaven Linux - Newbie 10 04-07-2015 05:33 AM
how to prove working of RS-232 full modem working PC to PC and LOOP BACK getasif Programming 2 08-20-2011 09:58 AM
alias in /etc/profile not working samogensen Linux - Server 1 07-05-2007 08:50 PM
Alias not working tofani Linux - General 7 11-29-2005 03:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:13 PM.

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