Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-19-2015, 09:28 PM   #1
LQ Newbie
Registered: Sep 2015
Posts: 2

Rep: Reputation: Disabled
scp not accept parameters in shell script

Hello everybody.
I am working with a Ubuntu PC and a lot of Raspberry PI's around me.
All raspis are root because using all GPIO. All Computer has keypairs to each other. So no more passwd is needed.

I try to make copy more easy.

alias t102='scp test.txt root@'
test.txt 100% 63 0.1KB/s 00:00
alias t101='scp $klaus root@'
test.txt 100% 63 0.1KB/s 00:00

up to here all is running well.

Now try to give parameter to scp

alias t101='scp $1 root@'
t101 test.txt
scp: /root: not a regular file
How can I solve this problem?


Old 09-19-2015, 10:28 PM   #2
Registered: Nov 2012
Posts: 204

Rep: Reputation: 67
You can't pass arguments to an alias like that, the arguments will always come at the end. You will need to make a function instead. The 2nd answer here might be exactly what you are looking for:

Last edited by af7567; 09-19-2015 at 10:29 PM. Reason: autocomplete error
Old 09-19-2015, 10:50 PM   #3
LQ Newbie
Registered: Sep 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quick and not dirty!

@ af7567

Thank You very much.
It works as it is written there.

And, thank you more, I learned about to handle C-Code:-)

regards from Germany



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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to use scp in a shell script Thaidog Programming 4 04-04-2011 03:10 PM
Shell script that reads from parameters file carters2 Linux - Newbie 4 11-04-2009 08:24 AM
shell script (sending parameters to scripts) qrshat Programming 4 12-05-2007 12:15 PM
Passing parameters to a shell script neocookie Linux - General 5 10-20-2005 11:44 AM
passing parameters to functions in shell script kushalkoolwal Programming 1 09-28-2005 02:40 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:23 PM.

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