The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help in replacing text with the value of a variable lotto_123 Shell Programming and Scripting 4 06-13-2008 04:39 AM
sed to replace text with a variable orahi001 UNIX for Dummies Questions & Answers 1 03-06-2008 05:25 PM
How to make a number in a text file a variable? nortypig Shell Programming and Scripting 5 08-23-2006 06:43 AM
how to insert text using variable mopimp Shell Programming and Scripting 1 03-24-2006 04:32 PM
grep multiple text files in folder into 1 text file? coppertone UNIX for Dummies Questions & Answers 7 08-23-2002 11:50 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-24-2008
Registered User
 

Join Date: Jul 2008
Posts: 8
Stumble this Post!
Text file to a variable


I have a variable which is not being populated with the contents of a text file, and I'm wondering if anyone happens to know how to do this for a sh type script?

#!/bin/sh
set alertperson = cat /export/home/bdodym/alert.person
if [ -f /export/home/bdodym/critabend.tag ]
then
cat /export/home/bdodym/callout6.msg | rmail $alertperson
rm /export/home/bdodym/critabend.tag
fi

Basically, the alertperson variable is not reading the contents of /alert.person (which is a text file simply containing 1 email address).

I appreciate any assistance....

Tim
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-24-2008
Ikon's Avatar
Registered User
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 247
Stumble this Post!
Code:
alertperson=`cat /export/home/bdodym/alert.person`
Reply With Quote
  #3 (permalink)  
Old 07-24-2008
Registered User
 

Join Date: Jul 2008
Posts: 8
Stumble this Post!
I wish it were that easy Ikon!

Amended script:
#!/bin/sh

alertperson = cat /export/home/bdodym/alert.person
echo $alertperson
if [ -f /export/home/bdodym/critabend.tag ]
then
cat /export/home/bdodym/callout6.msg | rmail $alertperson
rm /export/home/bdodym/critabend.tag
fi

Response:
6check2.sh: alertperson: not found

Recipient names must be specified
Reply With Quote
  #4 (permalink)  
Old 07-24-2008
joeyg's Avatar
premier etoile de match
 

Join Date: Dec 2007
Location: Home of world champion Boston Celtics
Posts: 625
Stumble this Post!
Wink

Beware of character spacing - very important in the world of unix.

Code:
alertperson=$(cat /export/home/bdodym/alert.person)
echo $alertperson
Reply With Quote
  #5 (permalink)  
Old 07-24-2008
Registered User
 

Join Date: Jul 2008
Posts: 8
Stumble this Post!
...thankyou, but still its proving tricky this!!

Amended script:
#!/bin/sh

alertperson=$(cat /export/home/bdodym/alert.person)
echo $alertperson
if [ -f /export/home/bdodym/critabend.tag ]
then
cat /export/home/bdodym/callout6.msg | rmail $alertperson
rm /export/home/bdodym/critabend.tag
fi

Response:
6check2.sh: syntax error at line 3: `alertperson=$' unexpected
Reply With Quote
  #6 (permalink)  
Old 07-24-2008
joeyg's Avatar
premier etoile de match
 

Join Date: Dec 2007
Location: Home of world champion Boston Celtics
Posts: 625
Stumble this Post!
Question

What is in your file alert.person?

Code:
> cat ~/tmp/alert/alert.person
Mickey Mouse
> alertperson=$(cat ~/tmp/alert/alert.person)
> echo $alertperson
Mickey Mouse
> echo "$alertperson"
Mickey Mouse
Reply With Quote
  #7 (permalink)  
Old 07-24-2008
Ikon's Avatar
Registered User
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 247
Stumble this Post!
worked for me... It put the contents of alert.person in the variable $alertperson.

Code:
# echo "Jim Smith" > alert.person
# alertperson=`cat alert.person`; echo $alertperson
Jim Smith
#
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0