script output not proper using kickstart installation

Hi All,

I am creating a custom iso in which i need to transfer one small script via kickstart.cfg file to /etc/profile in post installation section but it wont copied cleanly:

cat >> /usr/local/bin/script << EOF_script

#!/bin/bash

PROCCOUNT=`ps -l | wc -l`
PROCCOUNT=`expr $PROCCOUNT - 4`
if [[ $(groups) == *irc* ]]; then
ENDPROC=`cat /etc/security/limits.conf | grep "@irc" | grep nproc | awk {'print $4'}`
ENDSESSION=`cat /etc/security/limits.conf | grep "@irc" | grep maxlogins | awk {'print $4'}`
PRIVLAGED="IRC Account"
else
ENDPROC=`cat /etc/security/limits.conf | grep "*" | grep nproc | awk {'print $4'}`
ENDSESSION="Unlimited"
PRIVLAGED="Regular User"
fi

echo -e "

+++++++++++++++++: System Data :+++++++++++++++++++
+ Hostname = `hostname`
+ Address = `/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
+ Kernel = `uname -r`
+ Server Installation Date = `rpm -qi basesystem | grep Install | cut -c 15-46`
+ Uptime = `uptime | sed 's/.*up ([^,]*), .*/1/'`
+ No of CPU = `grep processor /proc/cpuinfo | wc -l`
+ `lscpu | grep 'socket'`
+ Memory = `cat /proc/meminfo | grep MemTotal | awk {'print $2'}` kB
++++++++++++++++++: User Data :++++++++++++++++++++
+ Username = `whoami`
+ Privlages = $PRIVLAGED
+ Sessions = `who | grep $USER | wc -l` of $ENDSESSION MAX
+ Processes = $PROCCOUNT of $ENDPROC MAX
+++++++++++++++++++++++++++++++++++++++++++++++++++
"

EOF_script

above data should be copied as it is in /etc/profile to run properly but actually it get copied the output of above commands.

kindly help - i tried with echo"" also but same thing happening
The RockAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gelonidaCommented:
could you just try with a simpler example and then enhance step by step till it breaks?

Two other small questions.
Why do you >> /usr/local/bin/script
this should be
> /usr/local/bin/script

>> appends to an existing script, but if you append, then the line
#!/bin/bash is useless as it works only as the first line of a script.

I'd suggest to try
cat >> /usr/local/bin/script << EOF_script
#!/bin/bash
touch /tmp/afile
EOF_script

Open in new window


make also sure that you have no trailing white spaces in the lines containing 'EOF_script'

Will the file be created?
0
The RockAuthor Commented:
thanks for your feedback - actually most of the part copied sucessfully but issues is this it copied after the command executed . but i want it to go without execution .i dont want ouput i want same script as it is after kickstart installation
0
The RockAuthor Commented:
For example

Hostname = `hostname` line copied as Hostname = local.domain which i dont want.

i want it as Hostname = `hostname` only
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

gelonidaCommented:
OK. please look at following script
#!/bin/bash

a=3

echo without quotes
cat << eot
$a b c `date`
eot

echo with single quotes
cat << 'eot'
$a b c `date`
eot

Open in new window


and its output:
without quotes
3 b c Tue, Apr 14, 2015  6:27:28 PM
with single quotes
$a b c `date`

Open in new window


if you don't want  expansion in the << eot, then use quotes
0
The RockAuthor Commented:
Thank you looks good - i will test it tommorrow and let you know.

I have also post 2 more question for kickstart only - if you get chance please have a look and advice! thanks
0
gelonidaCommented:
Well I hope my answer helps.
Unfortunaely I don't know kickstart, so probably can't help a lot there.
0
The RockAuthor Commented:
Hi Gelonida - it didnt work - even bad then before - kindly help
0
gelonidaCommented:
Could you post your changed script?
Or perhaps even better:
the shortest possible script that shows the problem?

did you use cat or did you use echo?
0
The RockAuthor Commented:
Here it is:

cat >> `/usr/local/bin/dynmotd' << EOF_dynmotd


#!/bin/bash

PROCCOUNT=`ps -l | wc -l`
PROCCOUNT=`expr $PROCCOUNT - 4`
if [[ $(groups) == *irc* ]]; then
ENDPROC=`cat /etc/security/limits.conf | grep "@irc" | grep nproc | awk {'print $4'}`
ENDSESSION=`cat /etc/security/limits.conf | grep "@irc" | grep maxlogins | awk {'print $4'}`
PRIVLAGED="IRC Account"
else
ENDPROC=`cat /etc/security/limits.conf | grep "*" | grep nproc | awk {'print $4'}`
ENDSESSION="Unlimited"
PRIVLAGED="Regular User"
fi

echo -e "

+++++++++++++++++: System Data :+++++++++++++++++++
+ Hostname = `hostname`
+ Address = `/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
+ Kernel = `uname -r`
+ Server Installation Date = `rpm -qi basesystem | grep Install | cut -c 15-46`
+ Uptime = `uptime | sed 's/.*up ([^,]*), .*/1/'`
+ No of CPU = `grep processor /proc/cpuinfo | wc -l`
+ `lscpu | grep 'socket'`
+ Memory = `cat /proc/meminfo | grep MemTotal | awk {'print $2'}` kB
++++++++++++++++++: User Data :++++++++++++++++++++
+ Username = `whoami`
+ Privlages = $PRIVLAGED
+ Sessions = `who | grep $USER | wc -l` of $ENDSESSION MAX
+ Processes = $PROCCOUNT of $ENDPROC MAX
+++++++++++++++++++++++++++++++++++++++++++++++++++
"

EOF_dynmotd

Open in new window

0
gelonidaCommented:
Well you did not put single quotes around the word EOF_dynmotd


What's also strange is, that you put a backtick ( ` ) before the filename
/usr/local/bin/dynmotd instead of a single quote ( ' )
As long as the filename does not contain any special characters and no white space you can keep the quotes off.

Please try with:
cat >> '/usr/local/bin/dynmotd' << 'EOF_dynmotd'

Open in new window


or with:
cat >> /usr/local/bin/dynmotd << 'EOF_dynmotd'

Open in new window


both should work
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The RockAuthor Commented:
Thank you it works fine .nice one
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.