Some doubts with Shell Scripting.
I have a couple of requirements to be satisfied using shell scripts. Since I am trio in this area, i would certainly need your help.
1) I have a script which invokes a env-function which will ask for a user input to proceed with the execution. I want my script to supply the answer to this. How can i implement this.Doing a bit of googling pointed me to an "expect" command, which is unfortunately not installed in my system. Is there any other way to achieve this task?
2) I have another requirement like, the script should find the total number of CPUs in my pc and should append the "-j(2*no.开发者_StackOverflow社区 of CPU)" to my make command.
Could somebody please shed some light into how this can be done.
Thanks,
SenSince the first part has been answered, for the 2nd part you can try something like
#!/bin/sh
cpu=`cat /proc/cpuinfo | grep -e '^processor' | wc -l`
jobs=$(echo "$cpu * 2" | bc)
make -j$jobs
I have another requirement like, the script should find the total number of CPUs in my pc
You can read the output of
/proc/cpuinfo
or even better:
You can narrow down output with the following command, to display number of processors in the system:
grep processor /proc/cpuinfo
you can simply redirect an input to that program. An example with checkinstall:
checkinstall < /path/to/file/with/answers
精彩评论