LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 09-19-2015, 10:28 PM   #1
oldfreak
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@192.168.1.102:/root'
t102
test.txt 100% 63 0.1KB/s 00:00
klaus=test.txt
alias t101='scp $klaus root@192.168.1.102:/root'
t101
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@192.168.1.102:/root'
t101 test.txt
scp: /root: not a regular file
How can I solve this problem?

regards

oldfreak
 
Old 09-19-2015, 11:28 PM   #2
af7567
Member
 
Registered: Nov 2012
Posts: 156

Rep: Reputation: 54
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: http://stackoverflow.com/questions/4...riable-in-bash

Last edited by af7567; 09-19-2015 at 11:29 PM. Reason: autocomplete error
 
Old 09-19-2015, 11:50 PM   #3
oldfreak
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

oldfreak
 
  


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 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 04:10 PM
Shell script that reads from parameters file carters2 Linux - Newbie 4 11-04-2009 09:24 AM
shell script (sending parameters to scripts) qrshat Programming 4 12-05-2007 01:15 PM
Passing parameters to a shell script neocookie Linux - General 5 10-20-2005 12:44 PM
passing parameters to functions in shell script kushalkoolwal Programming 1 09-28-2005 03:40 PM


All times are GMT -5. The time now is 05:13 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration