LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-03-2009, 07:23 AM   #1
netstrider
Member
 
Registered: Jan 2007
Location: South Africa
Posts: 72

Rep: Reputation: 15
I want to script


Hello,

I want to be able to do basic scripting tasks such as manipulating text files, directories etc. Making backup scripts and such as well as perhaps later on making functional programs.

I've looked at Python mostly and it seems it will fit my needs, however I was wondering if I wanted to manipulate files and directories on a UNIX system via Python am I not going to need to know BASH anyhow?

If so, would you recommend learning BASH first?

How would Ruby and Perl compare?

Thanks in advance
 
Old 01-03-2009, 07:37 AM   #2
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Manipulating files and directories (e.g. copying, moving, removing, appending to, &c.) you would want to use Bash. Python can do it, but it will take three times as much code. Shells rule for system administrative type tasks. But for general programming, definitely you will have to learn a language like Perl, Python, and Ruby. All three of the latter are great choices; I consider Perl more concise and better for smallish programs and Python better for larger systems, Ruby somewhere in between. But that's just my opinion so you'll just have to take a look at them to find out which one suits you best.
 
Old 01-03-2009, 07:38 AM   #3
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
For manipulating text files you could use sed, grep or awk. I'm not sure if bash would be helpful learning python (apart from the fact that it's possible to run bash commands from within python programs) but knowing bash is generally very useful. Sometimes it may be quicker to do something in bash, sometimes python will do the job better, etc.

Quote:
How would Ruby and Perl compare?
I can't help you with it, but here is a thread about perl/python/ruby.
 
Old 01-03-2009, 07:49 AM   #4
netstrider
Member
 
Registered: Jan 2007
Location: South Africa
Posts: 72

Original Poster
Rep: Reputation: 15
Thank you both for your input!

My actual "programming problem" lies with my ppp internet connection (USB).

Every now and again it would disconnect (it's wireless) and I would have to manually use "sudo pon neotel" to reconnect it again and I have to do sudo modprobe usbserial vendor=0x1d09 product=0x4000 every time after booting then sudo pon neotel.

Basically I want this to be done automatically via some script. It must automatically connect when I boot my comp and automatically reconnect when it has disconnected.

Bash would be the easiest I presume?
 
Old 01-03-2009, 07:52 AM   #5
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
For these kind of problems which lie closely to the OS, yes, use Bash. Probably you want to check you connectivity and undertake some action based on that. Something you now do manually on the command line, if you automate it, it is logical to do that in Bash.

See my signature for a link to the Bash programming guide.

jlinkels
 
Old 01-03-2009, 07:59 AM   #6
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
@jlinkels

Your link about GAWK seems to be broken. They might have moved the site.
 
Old 01-03-2009, 08:06 AM   #7
netstrider
Member
 
Registered: Jan 2007
Location: South Africa
Posts: 72

Original Poster
Rep: Reputation: 15
Thanks again,

I will look into Bash and probably learn Python or Ruby too for my normal programming.
 
Old 01-03-2009, 08:23 AM   #8
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by sycamorex View Post
@jlinkels

Your link about GAWK seems to be broken. They might have moved the site.
Fixed it. Although both linked documents about AWK cover the same subject they differ in content.

Thanks.

jlinkels
 
Old 01-03-2009, 08:39 AM   #9
dhanyaelizabeth
LQ Newbie
 
Registered: Jan 2009
Posts: 27

Rep: Reputation: 15
I think you should also add Java to the list of languages listed by the other members above (vis-a-vis Perl, Python, and Ruby). Using it - you can all the things you wanted to do too!


Linux Archive

Last edited by dhanyaelizabeth; 01-10-2009 at 03:12 PM.
 
  


Reply



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
How to execute a ssh script on Linux server from Windows through a bat script? wanna13e Programming 13 10-23-2009 02:41 AM
set variables in a bash script; ansi PS1 color script donnied Programming 4 11-21-2007 11:33 AM
Shell Script: want to insert values in database when update script runs ring Programming 2 10-25-2007 10:48 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 04:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:44 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