Bonjour,
most of the time I'm working in text mode on several computers.
So, Porteus is loaded either from sda4 or sdb5 or sdh1 ...
Maybe a $porteus global variable should be set (like $PATH ..)
$porteus=/mnt/sdxx/porteus
I'm using a local variable defined in .bash_profile
issued from /mnt/live/var/log/livedbg
I vote for "cd $porteus" instead "cd /mnt/sd??/porteus" without knowing sd??
Where are these global variables located?
Someone has a way to do ?
thanks
How to create a global variable
- fanthom
- Moderator Team
- Posts: 5588
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Re: How to create a global variable
hello bour59,
please add 2 lines to /etc/profile:
this variable will be set by default in Porteus 1.1
Cheers
please add 2 lines to /etc/profile:
Code: Select all
# export Porteus booting device:
export porteus=`awk 'c-->0;/Porteus data found in/{c=1}' /mnt/live/var/log/livedbg`
Cheers
Please add [Solved] to your thread title if the solution was found.
-
- Samurai
- Posts: 170
- Joined: 29 Dec 2010, 08:10
- Distribution: porteus v5.0-xfce K5.19.7
- Location: France
Re: How to create a global variable [Solved]
Many thanks. I was using in .bash_profie
Ill see Hamza's soluce later
It's time for me to learn awk
Good pub to have a porteus variable very usefull
http://porteus.org/forum/posting.php?mo ... f=81&t=798#
Code: Select all
old_IFS=$IFS ; IFS=$'\n' ; i=1
for line in $(cat /mnt/live/var/log/livedbg) ; do
array[$i]=$line ; ((i+=1)) ; done
IFS=$old_IFS
for ((i=1; i<=${#array[@]};i++)) ; do
case ${array[$i]:0:6} in
'# Port')
export porteus=${array[$i+1]};;
esac
done
It's time for me to learn awk
Good pub to have a porteus variable very usefull
http://porteus.org/forum/posting.php?mo ... f=81&t=798#
-
- Samurai
- Posts: 170
- Joined: 29 Dec 2010, 08:10
- Distribution: porteus v5.0-xfce K5.19.7
- Location: France
Re: How to create a global variable
@hamza : hello!
you wrote
Please is there a right way to get the porteus boot device into a variable
Thanks
you wrote
Can you tell me more about these troublesPostby Hamza » 28 Jan 2012, 12:10
It was possible to track directly the porteus boot device by using $porteus variable but it has been removed due to some reported user's troubles.
Please is there a right way to get the porteus boot device into a variable
Thanks
Re: How to create a global variable
fanthom should answer you as he had made and removed this variable.
NjVFQzY2Rg==
- fanthom
- Moderator Team
- Posts: 5588
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Re: How to create a global variable
Global variables are bad.Can you tell me more about these troubles
let's say we have porteus variable set globally which is used in many porteus scripts. user is not aware of this variable and exports it's own global variable under the same (porteus) name. result: all porteus scripts are broken.
i would rather create external library containing porteus specific variables (like booting device, changes directory, xxx) and functions (create_module, find_and_run_scripts, xxx) and import this lib when necessary. have a look on slax's /usr/lib/liblinuxlive which is used in activate, xzm2dir, etc scripts.
i see nothing wrong with using global variables when you are the only user of the system.
Please add [Solved] to your thread title if the solution was found.
- brokenman
- Site Admin
- Posts: 6104
- Joined: 27 Dec 2010, 03:50
- Distribution: Porteus v4 all desktops
- Location: Brazil
- Contact:
Re: How to create a global variable
I agree. Global variables can be useful, but they need to have unique names. I fell into this trap with porteus global variable while writing PPM. It's not too much harder to grab the path from porteus-livedbg.
How do i become super user?
Wear your underpants on the outside and put on a cape.
Wear your underpants on the outside and put on a cape.