LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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

Reply
 
Search this Thread
Old 10-29-2006, 06:02 AM   #16
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,470
Blog Entries: 54

Rep: Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900

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...
 
Old 10-29-2006, 03:29 PM   #17
hoodedmanwithsythe
Member
 
Registered: Apr 2006
Location: West Midlands, UK
Distribution: mandriva, centos, debian
Posts: 91

Original Poster
Rep: Reputation: 15
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

Last edited by hoodedmanwithsythe; 10-29-2006 at 03:47 PM.
 
Old 10-29-2006, 03:54 PM   #18
hoodedmanwithsythe
Member
 
Registered: Apr 2006
Location: West Midlands, UK
Distribution: mandriva, centos, debian
Posts: 91

Original Poster
Rep: Reputation: 15
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?

Last edited by hoodedmanwithsythe; 10-29-2006 at 03:55 PM.
 
Old 10-30-2006, 10:02 AM   #19
soggycornflake
Member
 
Registered: May 2006
Location: England
Distribution: Slackware 10.2, Slamd64
Posts: 249

Rep: Reputation: 31
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!

Last edited by soggycornflake; 10-30-2006 at 10:10 AM.
 
Old 10-30-2006, 12:02 PM   #20
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,470
Blog Entries: 54

Rep: Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900
@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

Last edited by unSpawn; 10-30-2006 at 12:08 PM.
 
Old 10-30-2006, 01:14 PM   #21
soggycornflake
Member
 
Registered: May 2006
Location: England
Distribution: Slackware 10.2, Slamd64
Posts: 249

Rep: Reputation: 31
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.
 
Old 10-31-2006, 08:32 AM   #22
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,470
Blog Entries: 54

Rep: Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900Reputation: 2900
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.
 
Old 11-05-2006, 03:49 PM   #23
hoodedmanwithsythe
Member
 
Registered: Apr 2006
Location: West Midlands, UK
Distribution: mandriva, centos, debian
Posts: 91

Original Poster
Rep: Reputation: 15
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
 
Old 11-05-2006, 03:59 PM   #24
hoodedmanwithsythe
Member
 
Registered: Apr 2006
Location: West Midlands, UK
Distribution: mandriva, centos, debian
Posts: 91

Original Poster
Rep: Reputation: 15
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
 
Old 11-05-2006, 04:17 PM   #25
soggycornflake
Member
 
Registered: May 2006
Location: England
Distribution: Slackware 10.2, Slamd64
Posts: 249

Rep: Reputation: 31
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?
 
Old 11-05-2006, 05:46 PM   #26
hoodedmanwithsythe
Member
 
Registered: Apr 2006
Location: West Midlands, UK
Distribution: mandriva, centos, debian
Posts: 91

Original Poster
Rep: Reputation: 15
done mods added
Script alone
Installer
Patch
use which ever you please
i surjest the patch for less hassle

Last edited by hoodedmanwithsythe; 11-05-2006 at 05:48 PM.
 
  


Reply

Tags
args, arguments, blender, python, qus, scripting, shell


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
running a command with args from a shell script KM3 Programming 3 10-19-2006 01:46 PM
three shell script questions qrshat Programming 4 02-27-2006 08:40 AM
Couple of Shell Script Questions mathias1979 Programming 3 06-16-2005 03:22 PM
two shell script questions tutwabee Linux - General 4 08-10-2004 06:03 PM
Shell Script Questions Col Panic Linux - General 13 10-12-2003 12:51 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration