LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 02-17-2011, 05:48 PM   #1
sfx81
LQ Newbie
 
Registered: Feb 2011
Posts: 2

Rep: Reputation: 0
Linux scripting


Hi All, I recently started learning linux. When people say shell scripting, does it always has to be bash/c/k shells ? Can't I just use perl/python ? PS will it still be quick as shall ?
 
Old 02-17-2011, 05:53 PM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
You can you can use them just the same way, except instead of
Code:
#!/bin/bash
at the start of your script, you'd use
Code:
#!/usr/bin/python
(or perl!)

However, when people say "shell scripting" they normally are talking about bash scripts, in my experience. And I think the performance would be comparable, if not better
 
Old 02-17-2011, 06:25 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,942

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by sfx81 View Post
Hi All, I recently started learning linux. When people say shell scripting, does it always has to be bash/c/k shells ? Can't I just use perl/python ? PS will it still be quick as shall ?
I agree with Snark, but there's a bit of a distinction in my mind.

Perl and Python are interpreted languages (http://en.wikipedia.org/wiki/Interpreted_language), whereas bash and other 'shells' are more of a command environment. You can do SOME programming in bash, but if you want to go beyond basic functions, you're going to find yourself struggling. Perl and python (and there are others), are 'real' programming languages, capable of doing object-oriented processing, GUI windows, and serious math, amongst others.

Think about it like this..in Windows, you can write a batch file to do alot of different things. That's the equivalent of BASH scripting. More power needed? Then you're going to have to go to a different language, like perl, which gives you more programming power. Yes, you can 'compile' perl (check out the perl packager), to ship executables without shipping your source code. Those languages run a bit slower, since the code is 'compiled' at run time, versus being pre-compiled like a C program would be...but once they're both running, the difference isn't that bad.
 
Old 02-17-2011, 08:42 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
... and in actual fact for Perl, it (perl binary) reads your Perl prog an 'compiles it on the fly', then runs the 'compiled' version in memory.
Read this for the details http://www.perl.com/doc/FMTEYEWTK/comp-vs-interp.html. The net effect is that it's not that much slower than an equiv C prog (85% ?).
Contrast with any of the shells eg ksh/bash which are true interpreted langs ie each cmd is re-parsed into machine lang each time it is called. Much slower than C or even Perl.
 
Old 02-18-2011, 08:41 AM   #5
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
Quote:
Originally Posted by chrism01 View Post
... and in actual fact for Perl, it (perl binary) reads your Perl prog an 'compiles it on the fly', then runs the 'compiled' version in memory.
I'm pretty sure this is also done in python... Not entirely certain though
 
Old 02-18-2011, 11:03 AM   #6
yngwin
Member
 
Registered: Dec 2002
Location: China
Distribution: Arch
Posts: 359

Rep: Reputation: 33
Shell scripting is specific to the shell, and is normally bash (altho other shells are sometimes also used). Perl, Python and similar interpreted programming languages are not normally used as shell (altho at least with Python this is possible). It is still scripting, but it works a bit different.
 
  


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
LXer: Scripting the Linux desktop, Part 2: Scripting Nautilus LXer Syndicated Linux News 0 02-17-2011 05:02 AM
Linux scripting 151803 Linux - Newbie 11 03-23-2007 11:21 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 05:29 AM
Linux Scripting SainT1337 Linux - General 3 11-30-2003 02:12 PM


All times are GMT -5. The time now is 05:00 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration