args or questions in a shell script which is easyer
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
This would require a compiled program that was written in source not in shell
Huh? I only meant you can grep them /etc/release files for clues...
oh right sorry i didn't understand your pervious post properly.
but it doesn't matter too much notw any ways as i have finnished the script and put it into an installer,
if you don't mind i will put your allias name and the forum that you have helped me on into my post on the blender forums.
on a slight asside i think it may be more conveniant to make a patch for the blender wrapper shell script that builds my script into the file, any ideas on how to make a patch file do you?
Last edited by hoodedmanwithsythe; 10-29-2006 at 03:55 PM.
So it turns out that bash has a builtin platform checker, so i guess it is time for me to get working on the final coding of my blender starter program.
$HOSTTYPE seems to be specific to bash (I don't have it in zsh, only $MACHTYPE, which is just i686). Not everyone uses bash. I don't even have bash installed on some of my systems, /bin/bash is just a symlink to /bin/zsh!! Also, non-Linux systems may not have bash either.
How about:
Code:
if [[ -n "$(file -L /bin/sh | grep 32-bit)" ]]; then
# 32-bit system
else
# 64-bit system
fi
Assuming that everyone has file, grep and /bin/sh is a pretty safe bet!
Last edited by soggycornflake; 10-30-2006 at 10:10 AM.
@hoodedmanwithsythe: oh right sorry i didn't understand your pervious post properly.
Yes, I thought so...
if you don't mind i will put your allias name and the forum that you have helped me on into my post
Since I didn't do nothing, I do mind.
on a slight asside i think it may be more conveniant to make a patch for the blender wrapper shell script that builds my script into the file, any ideas on how to make a patch file do you?
Save a copy of the file to say file.old. Edit file and make your changes. Now "diff -u file.old file > file.patch" and there's your patch. Test with "patch --dry-run file < file.patch" and apply with "patch file < file.patch".
@soggycornflake: Not everyone uses bash. I don't even have bash installed on some of my systems, /bin/bash is just a symlink to /bin/zsh!! Also, non-Linux systems may not have bash either. (..)
Compatibility lint check. Cool. Blender runs on GNU/Linux, FreeBSD, MacOSX, Solaris and IRIX. Some of those favour Korn Shell as default. Next to that the Bourne Shell may not be installed or be in another part of their $PATH or not be an allowed admin shell. Next to that Bourne Shell doesn't have a builtin "[[" (use test or "[") nor does it have "$(...)" command substitution syntax (use backticks). So if you want to check "sh" with "file" and favour Bourne Shell compatibility you would first have to iterate through $PATH elements to fix the location of the shell if it is not in a default location and then do something like (checked in the uber-strict Heirloom Shell):
Code:
for i in `file -L $SHELL_LOC | grep 32-bit`; do
case $i in [0-9][0-9]-bit) echo $i; break;; esac
done
Duh, I forgot about [[ vs [ (shameful, Slackware uses ash for rc scripts... ) and $() vs ``.
(<slaps self with pocket LART>).
Quote:
Blender runs on GNU/Linux, FreeBSD, MacOSX, Solaris and IRIX. Some of those favour Korn Shell as default. Next to that the Bourne Shell may not be installed or be in another part of their $PATH or not be an allowed admin shell.
I assumed that every unix has a /bin/sh, which is more or less bourne compatible, whatever it may be symlinked to (even if it isn't the default/preferred shell). Am I wrong? If /bin/sh doesn't exist, the OP's script wouldn't run in the first place.
I assumed that every unix has a /bin/sh, which is more or less bourne compatible, whatever it may be symlinked to (even if it isn't the default/preferred shell). Am I wrong?
No, I guess assuming symlink existence is not wrong but testing is better, same goes for compatibility.
just a quicky, the only os in my experience that needs this setting at the start of the program is linux as mack and the others have the setting set when python is installed, also most linuxes have but mandriva and slack don't and possibly a couple of others suse always has i know this from experience.
the $MACHTYPE is the same as $HOSTTYPE and both are interchangeable in the case of my program
but that little script mod of yours should account for any slight probs that I amy have and so i will check to see if it works in-line now thanks
for i in `file -L $SHELL_LOC | grep 32-bit`; do case $i in [0-9][0-9]-bit) echo $i; break;; esac done
not worky on mine sorry's about that one,
Yes, $SHELL_LOC doesn't exist, I think unSpawn meant that you need to set it yourself by searching through $PATH to find the location of the binary. It's more work but a more reliable test.
Quote:
Originally Posted by unSpawn
No, I guess assuming symlink existence is not wrong but testing is better, same goes for compatibility.
Yes, I was assuming execution via the hash-bang. It's unlikely, but possible, that /bin/sh doesn't exist and the user is running the script "manually" via, e.g. 'ksh ./script.sh', in which case my previous code would break. Of course, it doesn't have to be /bin/sh, any binary would do, it's just knowing what the frell is guaranteed to exist? Anything?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.