LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-08-2006, 08:17 AM   #1
linux_newbee
LQ Newbie
 
Registered: Mar 2006
Location: India
Distribution: FC4
Posts: 11

Rep: Reputation: 0
Question Unix scrpting : Append to a file


I am trying to write a Unix script which does the following:

Append the
Code:
alias myserver='/usr/bin/myserver :$SOME_USERID -name  $SOME_USERNAME'
to the end of a particular file.

Can anyone help me with doing this ?

I tried the following
Code:
 echo "alias myserver='/usr/bin/myserver :$SOME_USERID -name $SOME_USERNAME'" >> .bashrc
But i am getting the following
invalid command name "echo"
while executing
"echo "alias
  1. Why is this happening ?
  2. Any other way to do the appending ?

Thanks in advance
 
Old 06-08-2006, 08:23 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
You've apparently defined an alias for echo. To display all your aliases:

alias

To remove an alias (also remember to remove it from any scripts executed at login):

unalias echo
 
Old 06-08-2006, 09:21 AM   #3
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
The left slash prevents an alias expansion for the following command.

Code:
$ \echo "whatever..."
will execute the internal bash echo, not an alias.
 
Old 06-08-2006, 11:58 PM   #4
linux_newbee
LQ Newbie
 
Registered: Mar 2006
Location: India
Distribution: FC4
Posts: 11

Original Poster
Rep: Reputation: 0
No i am not trying to create an alias for echo. I am trying to create an alias for "myserver"
 
Old 06-09-2006, 04:19 AM   #5
muha
Member
 
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 38
You're trying to do this right?
Code:
$ cat > file
test <CTRL+D>
$ echo "alias myserver='/usr/bin/myserver :\$SOME_USERID -name \$SOME_USERNAME'" >> file
$ cat file
test
alias myserver='/usr/bin/myserver :$SOME_USERID -name $SOME_USERNAME'
 
Old 06-12-2006, 06:14 AM   #6
linux_newbee
LQ Newbie
 
Registered: Mar 2006
Location: India
Distribution: FC4
Posts: 11

Original Poster
Rep: Reputation: 0
Yes.... this is what I am trying to do. This "file" is a script file. So i try to execute the file after i put the echo commands. but it gives me the error....
" invalid command name "echo" while executing "
 
Old 06-12-2006, 08:02 AM   #7
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
Quote:
Originally Posted by linux_newbee
No i am not trying to create an alias for echo. I am trying to create an alias for "myserver"
Yes, we understand this.
What we are talking, is maybe, there is, for some reason, an incorrect alias to echo.

try to put, as macemoneta pointed, "unalias echo", right before the echo "alias=whatever" in your script.
 
  


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
pipe output to append to a text file davee Linux - Newbie 5 03-22-2016 07:44 PM
c++ append data to file blizunt7 Programming 3 07-04-2005 12:47 AM
> writes a new file, how to append? luwigie Linux - General 1 08-26-2004 08:42 PM
tar append file juno Linux - General 5 10-24-2002 02:59 AM
append to file d-rez Linux - Newbie 2 06-20-2002 04:55 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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