![Avatar of The Rock](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
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
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
![Avatar of The Rock](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
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
![Avatar of The Rock](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
For example
Hostname = `hostname` line copied as Hostname = local.domain which i dont want.
i want it as Hostname = `hostname` only
Hostname = `hostname` line copied as Hostname = local.domain which i dont want.
i want it as Hostname = `hostname` only
![Avatar of gelonida](https://filedb.experts-exchange.com/files/public/2013/11/18/f98e21b5-08da-4307-8b08-8a1960b48e46.png)
OK. please look at following script
and its output:
if you don't want expansion in the << eot, then use quotes
#!/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
and its output:
without quotes
3 b c Tue, Apr 14, 2015 6:27:28 PM
with single quotes
$a b c `date`
if you don't want expansion in the << eot, then use quotes
![Avatar of The Rock](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
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
I have also post 2 more question for kickstart only - if you get chance please have a look and advice! thanks
![Avatar of gelonida](https://filedb.experts-exchange.com/files/public/2013/11/18/f98e21b5-08da-4307-8b08-8a1960b48e46.png)
Well I hope my answer helps.
Unfortunaely I don't know kickstart, so probably can't help a lot there.
Unfortunaely I don't know kickstart, so probably can't help a lot there.
![Avatar of The Rock](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
Hi Gelonida - it didnt work - even bad then before - kindly help
![Avatar of gelonida](https://filedb.experts-exchange.com/files/public/2013/11/18/f98e21b5-08da-4307-8b08-8a1960b48e46.png)
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?
Or perhaps even better:
the shortest possible script that shows the problem?
did you use cat or did you use echo?
![Avatar of The Rock](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
![Avatar of The Rock](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
Thank you it works fine .nice one
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
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?