SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello,
I am writing a SlackBuild script for an application. The odd thing is that the configure script of the application at some point prompts the user to enter a number from the terminal
and then goes on. Until one enters a number, it just hangs and waits. My question is, is there a way to provide the number (the answer) to the configure call in the SlackBuild script itself, so that it doesn't prompt and the package building runs smoothly?
The method you should use depends in the quality of the random number you need.
For cryptographic software, you want the best randomness you can get. You can surely obtain it by the clever use of openssl's "rand" and some scripting abilities.
If you don't need crypto-geek randomness, the Bash shell has a built in function to generate numbers between 0 and 32767. There is plenty of information about the $RANDOM function in search engines.
Please, tell us what software are you dealing with so we can decide upon facts.
The method you should use depends in the quality of the random number you need.
For cryptographic software, you want the best randomness you can get. You can surely obtain it by the clever use of openssl's "rand" and some scripting abilities.
If you don't need crypto-geek randomness, the Bash shell has a built in function to generate numbers between 0 and 32767. There is plenty of information about the $RANDOM function in search engines.
Please, tell us what software are you dealing with so we can decide upon facts.
Oh, no it has nothing to do with random numbers, actually it is a fixed number (25) that I must type from the console during the configure. Can I
provide that number in the script, so that no prompt comes? This number gives the architecture that the sources will be configured for, and in my case 25 means Linux 64 bit with gfortran and gcc.
If the configure script accepts the number as an option (i.e: you could use "./configure --number=25") or variable (i.e: you could use "NUMBER=25 ./configure"), then it is as easy as setting the variable from the start of the SlackBuild script. If you are using the classical template, you should find something like this somewhere:
Code:
# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 ;;
arm*) ARCH=arm ;;
# Unless $ARCH is already set, use uname -m for all other archs:
*) ARCH=$( uname -m ) ;;
esac
fi
You can modify this so it looks like:
Code:
# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 && NUMBER=whatever1;;
arm*) ARCH=arm && NUMBER=whatever2;;
# Unless $ARCH is already set, use uname -m for all other archs:
*) ARCH=$( uname -m ) && NUMBER=whatever3;;
esac
fi
When running configure, you would just pass it the NUMBER variable by the means accepted by the script. It would look like this, where the "number" option is the option that parses your 25:
Other tweaks may be needed, but I hope you get the idea.
If the configure script does not accept the number as an input, and supports only interactive prompting, then you are supposed to patch the ./configure script so it behaves like explained above. You can do this by having the ./configure script accept non-interactive modes or by making it figure the number by itself.
Last edited by BlackRider; 05-01-2012 at 06:56 AM.
Two ideas:
1) check to see if the install script that you are running has a help flag which might tell you a way to pass this number as an argument or an environment variable. For example, ./configure -h could tell you that calling ./configure --arch=25 is equivalent to providing the number during the script.
2) Patch the script so that instead of asking it just uses 25. Many SlackBuilds patch the source code or the Makefiles to fix problems, and in this case it shouldn't be too hard to remove the prompt and assign 25 to the variable in question.
Edit pkgname.SlackBuild's running of the configure command, something like echo 25 | ./configure ...
If that works you could implement it to use a variable value instead of 25 and set that variable before running pkgname.SlackBuild.
Thank you very much for your reply, it worked like a charm.
The configure script does not allow a parameter for this option, and the prompt actually comes from a perl script, so hacking it would not be easy for me.
But the echo-pipe thing worked perfectly, many thanks!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.