LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 11-20-2004, 03:29 PM   #1
pfaendtner
Member
 
Registered: Nov 2003
Posts: 57

Rep: Reputation: 15
bash variables


Hi,

I want to set a value equal to my ip address in my .bashrc file so I can do the following:


scp file1 me@$MYHOMEIPADDRESS:~/

from my bash prompt I know I can do set MYHOMEIP = xxx.xxx.xxx.xxx, and I can do echo $MYHOMEIP to get it to show me my address but when I try to use the variable in the scp command it doesn't work.


please help!
 
Old 11-20-2004, 03:41 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
You are using different variables - try:
scp file1 me@$MYHOMEIP:~/
 
Old 11-23-2004, 09:24 AM   #3
pfaendtner
Member
 
Registered: Nov 2003
Posts: 57

Original Poster
Rep: Reputation: 15
Question still doesn't work

I did have the same variable name, I was just sloppy...


here is what I do:

set WIFI = 192.168.0.1

(to test) ping $WIFI - works no problem

scp test.text $WIFI:~/ - doesn't work (i have the same user name on both machines so I don't need to put jim@$WIFI)

Bad : modifier in $ (~).

that's my error message.

anybody know how to get around this?
 
Old 11-23-2004, 11:18 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
just omit the ~/ then ...
scp will chuck copied stuff in your home by default.


Cheers,
Tink
 
Old 11-23-2004, 01:00 PM   #5
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
You could also stop the variable being expanded by using "${WIFI}" instead of "$WIFI"
 
  


Reply



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
(bash) how to list all variables? Duudson Programming 11 03-24-2005 12:35 PM
sed with bash variables MurrayL Linux - Software 2 03-21-2005 08:13 AM
variables in bash haddad Linux - General 6 09-22-2004 05:29 PM
Variables in bash tcaptain Programming 1 03-03-2003 02:07 PM
Bash variables pk21 Programming 2 01-09-2003 03:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:22 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