Slackware This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
|
01-27-2014, 03:16 PM
|
#16
|
Member
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 642
|
@astrogeek - er no ! The OP mentioned that he was THINKING of programming in bash. I believe that it's a monumental waste of time. I merely suggested a better alternative, which would do the job for him and would serve him better in the long run. I maintain that's good advice. And other people read these entries too. I have over 30 years programing experience (34 to be precise) and I have never encountered a more friendly language than Python.
|
|
|
01-27-2014, 03:29 PM
|
#17
|
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,264
Rep:
|
Replacing all shell scripts in Slackware by Python ones is left to Mark Pettit as an exercise
Last edited by Didier Spaier; 01-27-2014 at 03:30 PM.
|
|
2 members found this post helpful.
|
01-28-2014, 12:33 AM
|
#18
|
Member
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 642
|
Ho ho @didier. Don't laugh - I've actually thought of doing that before. It wouldn't really be such a big exercise. But I think that Slackware is maybe too conservative for such a step. If there was really a good chance that it would be accepted and used, then I do have the skills for it and I would give it a go. But nothing short of a personal invitation from Pat himself would get me going :-)
|
|
|
01-28-2014, 01:04 AM
|
#19
|
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,264
Rep:
|
Quote:
Originally Posted by Mark Pettit
But nothing short of a personal invitation from Pat himself would get me going :-)
|
Well, I may be wrong but I wouldn't hold my breath till this happens
(A little) more seriously, if you intend to optimize for speed, the only script that I can think off that could benefit of using another language is removepkg, because for each file to be removed it has to scan the whole database to check that it be not included in another package -- though it's already pretty fast for a shell script and you don't spend all day removing packages, do you?
Even then, there is already spkg from Ondřej Jirman that is an unofficial replacement of pkgtool and is used by Salix. This is a C program, so good luck to beat it with a Python script.
Oh, and while we are at it Asciidoctor, that is a Ruby implementation of AsciiDoc (a Python application), is claimed to be way faster than its genuine counterpart. To be honest I didn't try it, out of laziness, as AsciiDoc is shipped in Slackware and is fast enough for my needs (as is pkgtool, by the way).
Last edited by Didier Spaier; 01-28-2014 at 01:09 AM.
Reason: AsciiDoic is shipped in Slackware, not Asciidoctor
|
|
|
01-28-2014, 01:23 AM
|
#20
|
Member
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 642
|
No - don't recall running removepkg too often - isn't it used as part of an upgradepkg as well ?
Just for fun I'll take a look at it - your brief description above, if accurate, certainly points to something that can be better optimised. In many cases, Python scripts can beat C progams - simply on the fact that Python has things like lists and dictionaries and those are not easy to get in C, unless you pull in third-party libraries. Of course we're referring here to a better algorithm, not a direct (and daft) comparison between C and Python.
|
|
|
01-28-2014, 02:03 AM
|
#21
|
Senior Member
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860
|
Quote:
Originally Posted by Mark Pettit
@richard - can you give a clear(er) demo of how to do that [code] thing please ?
|
Hmm. I don't know if that's a tugging sensation that I feel on my leg, but here you go:
Just write whatever you want between [CODE] and [ /CODE] tags (without the space between "[" and "/"). Or paste whatever it is in the reply box, highlight it with your mouse, and click the # button that's available in the advanced reply.
So, writing
[CODE]#!/usr/bin/python
import sys, os
inp = raw_input("Would you like to enable multilib support? (Yes/No)").lower()
if inp == "no":
print "Ok, next step"
elif inp == "yes":
os.system("ls")
else:
print "Please choose a valid option"[ /CODE]
without that space between "[" and "/CODE]" will give you
Code:
#!/usr/bin/python
import sys, os
inp = raw_input("Would you like to enable multilib support? (Yes/No)").lower()
if inp == "no":
print "Ok, next step"
elif inp == "yes":
os.system("ls")
else:
print "Please choose a valid option"
This stuff is called BBCode.
|
|
1 members found this post helpful.
|
01-28-2014, 02:18 AM
|
#22
|
Senior Member
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860
|
Quote:
Originally Posted by Mark Pettit
@astrogeek - er no ! The OP mentioned that he was THINKING of programming in bash. I believe that it's a monumental waste of time. I merely suggested a better alternative, which would do the job for him and would serve him better in the long run. I maintain that's good advice. And other people read these entries too. I have over 30 years programing experience (34 to be precise) and I have never encountered a more friendly language than Python.
|
Well, I think that it's good to understand sh scripts (since they are all over the place). However, my go-to language for scripting is Python. Unlike Perl or awk, there's a very good chance that you can read and understand someone else's Python code. (Sadly "someone else" can even mean "me 5 years ago", unless you are talking about awk. Then it's "me 30 minutes ago".) IIRC, Gentoo's emerge system is all python based.
(I've got 37 years programming experience myself, which does include college.)
|
|
|
01-28-2014, 03:52 AM
|
#23
|
Member
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 642
|
Test :
Code:
for i in range(1,100):
print "Python rulez"
Tested !
Hey - cool. Thanx Richard.
|
|
|
01-28-2014, 10:02 AM
|
#24
|
Member
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 958
|
Code:
clear;tput civis;tput bold;color=30;rulez='Shell script rulez too';r_n=${#rulez};lines=$[$(tput lines)/3];cols=$[$(tput cols)/2-$r_n/2];tput cup $lines $cols;for i in $(seq 0 $[$r_n]);do color=$[color>36?color=31:++color];echo -en "\e[${color}m${rulez:i:1}";tput sc;sleep 0.1;[ $[i%2] -ne 0 ] && { tput cup $lines $[cols-1];tput el;};tput rc;done;sleep 0.5;for cont in 1 2;do for bg in {40..46};do tput cup $lines $cols;echo -e "\e[$[bg-8];${bg}m$rulez"' :)';sleep 0.2;done;done;sleep 2;tput reset
compatibility problem... only tested in bash 4.2.45, Slackware 14.1 default,
and we cannot call that one liner, maybe one "long" liner
|
|
1 members found this post helpful.
|
01-28-2014, 11:15 AM
|
#25
|
Member
Registered: May 2004
Distribution: BSD
Posts: 269
Rep:
|
Quote:
Originally Posted by Paulo2
Code:
clear;tput civis;tput bold;color=30;rulez='Shell script rulez too';r_n=${#rulez};lines=$[$(tput lines)/3];cols=$[$(tput cols)/2-$r_n/2];tput cup $lines $cols;for i in $(seq 0 $[$r_n]);do color=$[color>36?color=31:++color];echo -en "\e[${color}m${rulez:i:1}";tput sc;sleep 0.1;[ $[i%2] -ne 0 ] && { tput cup $lines $[cols-1];tput el;};tput rc;done;sleep 0.5;for cont in 1 2;do for bg in {40..46};do tput cup $lines $cols;echo -e "\e[$[bg-8];${bg}m$rulez"' :)';sleep 0.2;done;done;sleep 2;tput reset
compatibility problem... only tested in bash 4.2.45, Slackware 14.1 default,
and we cannot call that one liner, maybe one "long" liner
|
Nice one! This reminded me of some of the scripts you can find at
http://kantico.de/texray/scripts.xhtml (at the bottom of the page, `Other scripts').
|
|
1 members found this post helpful.
|
01-28-2014, 02:52 PM
|
#26
|
Member
Registered: May 2008
Location: Republic of Texas
Posts: 393
Rep:
|
_My_ li'l take on it (and Richard, I beat ya with 7 yrs!!) ...
If you want to learn linux: bash, awk, sed and all the other trimmings
If you want to learn programming: Yeah, python is not a bad place to start, though I still maintain that the easiest to learn is 'c' (because of its compactness)
Just my 2c-worth ...
|
|
|
01-28-2014, 02:59 PM
|
#27
|
Member
Registered: May 2008
Location: Republic of Texas
Posts: 393
Rep:
|
... sorry, double-posted *gasp*
Last edited by perbh; 01-29-2014 at 09:43 AM.
|
|
|
01-29-2014, 09:21 AM
|
#28
|
Member
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 958
|
Quote:
Originally Posted by lems
|
Thanks for the link checkinstall seems to be helpful
and I will try demoplay QuakeIII for sure
|
|
|
01-29-2014, 10:33 PM
|
#29
|
Senior Member
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860
|
Quote:
Originally Posted by perbh
... sorry, double-posted *gasp*
|
Yeah, that's something that Old Farts (TM) do.
|
|
|
All times are GMT -5. The time now is 12:35 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|