LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   args or questions in a shell script which is easyer (https://www.linuxquestions.org/questions/linux-newbie-8/args-or-questions-in-a-shell-script-which-is-easyer-496347/)

unSpawn 10-29-2006 06:02 AM

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...

hoodedmanwithsythe 10-29-2006 03:29 PM

changed code and made an installer
 
here is the new code;
Code:

#!/bin/bash
    PATH=/usr/ucb:/usr/bin:/bin; export PATH
# checking the platform
echo "checking Platform"
echo "Platform is "$HOSTTYPE
if [ "$HOSTTYPE" = "x86_64" ]
then        #Checking Python Directory
        echo "Setting PYTHONPATH for 64Bit OS"
        export PYTHONHOME=/usr/lib64/python2.4
        export PYTHONPATH=/usr/lib64/python2.4
        # loading blender
        echo "Running Blender"       
        /usr/bin/blender

else        # setting Python Directory
        echo "Setting PYTHONPATH for a 32Bit OS"
        export PYTHONHOME=/usr/lib/python2.4
        export PYTHONPATH=/usr/lib/python2.4
        # loading blender
        echo "Running Blender"
        /usr/bin/blender

fi
exit

and here is a link for downloading my installer

hoodedmanwithsythe 10-29-2006 03:54 PM

Quote:

Originally Posted by unSpawn
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?

soggycornflake 10-30-2006 10:02 AM

Quote:

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!

unSpawn 10-30-2006 12:02 PM

@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


soggycornflake 10-30-2006 01:14 PM

Duh, I forgot about [[ vs [ (shameful, Slackware uses ash for rc scripts... :o) 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.

unSpawn 10-31-2006 08:32 AM

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.

hoodedmanwithsythe 11-05-2006 03:49 PM

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

hoodedmanwithsythe 11-05-2006 03:59 PM

Quote:

Originally Posted by unSpawn
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


not worky on mine sorry's about that one,
where as in the case of
Code:

if [[ -n "$(file -L /bin/sh | grep 32-bit)" ]]; then
    # 32-bit system
else
    # 64-bit system
fi

i was under the impression that every unix base os has /bin/sh as a necessity

soggycornflake 11-05-2006 04:17 PM

Quote:

Originally Posted by hoodedmanwithsythe
Quote:
Originally Posted by unSpawn
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

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?

hoodedmanwithsythe 11-05-2006 05:46 PM

done mods added
Script alone
Installer
Patch
use which ever you please
i surjest the patch for less hassle


All times are GMT -5. The time now is 06:31 AM.