LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-27-2014, 03:16 PM   #16
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 642

Rep: Reputation: 304Reputation: 304Reputation: 304Reputation: 304

@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.
 
Old 01-27-2014, 03:29 PM   #17
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,264

Rep: Reputation: Disabled
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.
Old 01-28-2014, 12:33 AM   #18
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 642

Rep: Reputation: 304Reputation: 304Reputation: 304Reputation: 304
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 :-)
 
Old 01-28-2014, 01:04 AM   #19
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,264

Rep: Reputation: Disabled
Quote:
Originally Posted by Mark Pettit View Post
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
 
Old 01-28-2014, 01:23 AM   #20
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 642

Rep: Reputation: 304Reputation: 304Reputation: 304Reputation: 304
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.
 
Old 01-28-2014, 02:03 AM   #21
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860

Rep: Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229
Quote:
Originally Posted by Mark Pettit View Post
@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.
Old 01-28-2014, 02:18 AM   #22
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860

Rep: Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229
Quote:
Originally Posted by Mark Pettit View Post
@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.)
 
Old 01-28-2014, 03:52 AM   #23
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 642

Rep: Reputation: 304Reputation: 304Reputation: 304Reputation: 304
Test :

Code:
for i in range(1,100):
    print "Python rulez"
Tested !


Hey - cool. Thanx Richard.
 
Old 01-28-2014, 10:02 AM   #24
Paulo2
Member
 
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 958

Rep: Reputation: 541Reputation: 541Reputation: 541Reputation: 541Reputation: 541Reputation: 541

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.
Old 01-28-2014, 11:15 AM   #25
lems
Member
 
Registered: May 2004
Distribution: BSD
Posts: 269

Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by Paulo2 View Post

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.
Old 01-28-2014, 02:52 PM   #26
perbh
Member
 
Registered: May 2008
Location: Republic of Texas
Posts: 393

Rep: Reputation: 81
_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 ...
 
Old 01-28-2014, 02:59 PM   #27
perbh
Member
 
Registered: May 2008
Location: Republic of Texas
Posts: 393

Rep: Reputation: 81
... sorry, double-posted *gasp*

Last edited by perbh; 01-29-2014 at 09:43 AM.
 
Old 01-29-2014, 09:21 AM   #28
Paulo2
Member
 
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 958

Rep: Reputation: 541Reputation: 541Reputation: 541Reputation: 541Reputation: 541Reputation: 541
Quote:
Originally Posted by lems View Post
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').
Thanks for the link checkinstall seems to be helpful
and I will try demoplay QuakeIII for sure
 
Old 01-29-2014, 10:33 PM   #29
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860

Rep: Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229Reputation: 2229
Quote:
Originally Posted by perbh View Post
... sorry, double-posted *gasp*
Yeah, that's something that Old Farts (TM) do.
 
  


Reply


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
learning bash, where to get started? Cultist Linux - General 4 09-26-2011 03:23 PM
Learning how to use Bash Productively bartonski Linux - General 9 11-25-2009 05:24 PM
Need tips for learning 'bash' penguin386 Linux - Newbie 1 05-18-2009 07:58 PM
What is the BEST book on learning how to use Bash? Fabyfakid Linux - Newbie 1 08-28-2004 11:59 AM
Learning from shell's info bash ? jamaso Linux - Newbie 7 11-13-2001 10:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:35 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration