cat redirect EOF missing text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cat redirect EOF missing text
# 1  
Old 05-17-2010
cat redirect EOF missing text

Hello attempting to redirect out to create a startup script in solaris. The steps are working but the $1 entry is being left out. syntax below and content of output file below.


Code:
cat > S99build << EOF
> #!/bin/bash
> case $1 in
> 'start')
> /usr/os-buildsol.sh
>
> ;;
> esac
> exit 0
> EOF

The $1 is not coming across in the output file

Code:
cat S99build
#!/bin/bash
case  in
'start')
/usr/os-buildsol.sh

;;
esac
exit 0


Last edited by Scott; 05-26-2010 at 05:07 PM.. Reason: Please use code tags
# 2  
Old 05-17-2010
Variables are substitued inside HERE documents.
Try this :
Code:
cat > S99build << EOF
> #!/bin/bash
> case \$1 in
> 'start')
> /usr/os-buildsol.sh
>
> ;;
> esac
> exit 0
> EOF

Jean-Pierre.
# 3  
Old 05-17-2010
Try:
Code:
cat > S99build << "EOF"
> #!/bin/bash
> case $1 in
> 'start')
> /usr/os-buildsol.sh
>
> ;;
> esac
> exit 0
> EOF

By quoting EOF no expansions or substitutions are performed on the here document...

Last edited by Scrutinizer; 05-17-2010 at 04:33 PM..
# 4  
Old 05-17-2010
Variables are substitued inside HERE documents

Thanks all, it's working.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How To Redirect The Output When We Are Usinf EOF In The Same Line?

need to login 4 systems to check whether the systems are accessible or not using rlogin command,after each login i will exit.After issuing the command rlogin abc if it is not responding i will get a message of "connection timed out" . So i want to automate this task .so i tried like below: EX: ... (3 Replies)
Discussion started by: kankuro9x
3 Replies

2. Shell Programming and Scripting

How to redirect the output when we are usinf EOF in the same line?

need to login 4 systems to check whether the systems are accessible or not using rlogin command,after each login i will exit.After issuing the command rlogin abc if it is not responding i will get a message of "connection timed out" . So i want to automate this task .so i tried like below : EX:... (1 Reply)
Discussion started by: charanarjun
1 Replies

3. Shell Programming and Scripting

Cat files listed in text file and redirect to new directory with same filename

I have a directory that is restricted and I cannot just copy the files need, but I can cat them and redirect them to a new directory. The files all have the date listed in them. If I perform a long listing and grep for the date (150620) I can redirect that output to a text file. Now I need to... (5 Replies)
Discussion started by: trigger467
5 Replies

4. UNIX for Dummies Questions & Answers

How to append a string by cat and redirect to other file?

Hi, when I do cat for kernel parameters cat /proc/sys/kernel/sem >> /etc/sysctl.conf 4096 4096 32 128 The above command working with out any doubt but I want to pass it like below, need to append "kernel.sem =" and pass it to /etc/sysctl.conf kernel.sem = 4096... (2 Replies)
Discussion started by: stew
2 Replies

5. Shell Programming and Scripting

What's wrong with my cat EOF?

cat << EOF > tmp.sh #!/bin/sh mknod /dev/`cat /proc/devices | grep xx | sed -r 's/(.*) (.*)/\2 c \1/'` 0 chmod 777 /dev/xx (1 Reply)
Discussion started by: yanglei_fage
1 Replies

6. UNIX for Dummies Questions & Answers

Copying text from Windows to AIX - missing text?

Hi All, I'm hoping this is an easy question, but I'm having a weird problem trying to simply copy and paste text from MS Windows (XP) Notepad and then pasting into vi or vim in AIX. When I type "oslevel" I get "5.3.0.0". The problem is that once the text is pasted, there are sections of text... (2 Replies)
Discussion started by: PlainInverted
2 Replies

7. Shell Programming and Scripting

Adding timestamp after cat <<EOF >

Hi Team, I am trying to add timestamp to SQLs by taking the timestamp in variable through shell script.I started like this. cat << EOF > $MYDIR CONNECT TO $MYDB USER $MYUSR USING $MYPWD; T=`db2 -x "select CURRENT_TIMESTAMP from sysibm.sysdummy1 "`; DECLARE RECCUR CURSOR FOR... (3 Replies)
Discussion started by: rocking77
3 Replies

8. Shell Programming and Scripting

redirect cat to variable

hello just i saw a really strange for cat i have file (file1) contains line /home/rajiv/proj1/*.txt now applied a commonds DDPATH="$(cat file1)" echo $DDPATH it shows all the txt files in that folder like /home/rajiv/proj1/read1.txt /home/rajiv/proj1/read2.txt... (7 Replies)
Discussion started by: shailesh_arya
7 Replies

9. UNIX for Dummies Questions & Answers

regarding cat and EOF in UNIX

Hi, Can anyone explain me what this function is doing cat << EOF > HELPFILE /$1/ { print "SENT" } EOF Thanks in Advance Suggestions welcome (1 Reply)
Discussion started by: trichyselva
1 Replies

10. UNIX for Dummies Questions & Answers

using cat and grep to display missing records

Gentle Unix users, Can someone tell me how I can use a combination of the cat and grep command to display records that are in FileA but missing in FileB. cat FileA one line at a time and grep to see if it is in fileB. If it is ignore. If line is not in fileB display the line. Thanks in... (4 Replies)
Discussion started by: jxh461
4 Replies
Login or Register to Ask a Question