The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to attach a variable from the 2nd file to the 1st file lo tan Shell Programming and Scripting 5 06-03-2008 02:58 AM
Using a variable inside a file to cat another. MaestroRage UNIX for Dummies Questions & Answers 3 02-06-2008 02:17 PM
print variable in file using awk kamel.seg Shell Programming and Scripting 3 01-03-2008 06:43 AM
Put one ligne from a file a variable kykyboss AIX 1 11-13-2006 08:06 PM
How to get variable input from a file maheshsri Shell Programming and Scripting 1 10-29-2005 07:26 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-02-2008
pppswing pppswing is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 14
Smile variable into file

Hello,

I have a variable and I want to add this variable in a file (not to erase the file, only add, I guess >>).

Code:
 
#config
server="<server>Hostname</server>"
myfile=myfile.xml
net=true

if [net] then
echo $server >> $myfile
fi
I have a "syntax error near unexpected token fi".

  #2 (permalink)  
Old 07-02-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj -------
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 560
Quote:
Originally Posted by pppswing View Post
Hello,

I have a variable and I want to add this variable in a file (not to erase the file, only add, I guess >>).

Code:
 
#config
server="<server>Hostname</server>"
myfile=myfile.xml
net=true

if [net] then
echo $server >> $myfile
fi
I have a "syntax error near unexpected token fi".


Few points here:

- It should be $net to be tested
- It should be used like this:
Code:
        if $net
        then
        echo $server>> $myfile
        fi
  #3 (permalink)  
Old 07-02-2008
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
Quote:
Originally Posted by pppswing View Post
Hello,

I have a variable and I want to add this variable in a file (not to erase the file, only add, I guess >>).

Code:
 
#config
server="<server>Hostname</server>"
myfile=myfile.xml
net=true

if [net] then
echo $server >> $myfile
fi
I have a "syntax error near unexpected token fi".

use a semicolon after if statement or put then in the next line. The problem is coming beacuse of that only.
give a space before and after net in the if statement like this
if [ $net ];
then
Thanks

Last edited by namishtiwari; 07-02-2008 at 05:00 AM.. Reason: space before and after
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0