As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I would like to learn some scripting to help automate some common tasks. Is ruby a good language to learn for this and what gems will be useful?
I would like to make scripts similar to this bash script
http://nikhgupta.com/code/initialize-gitolite-bash-script/
Which automates setting up a new gitolite repo.
Would you just learn bash, sed grep etc?
Sounds like a job for Ruby and Rake! Check this out.
In my opinion, Python and Ruby are the best languages out there, when it comes to automating tasks in *NIX systems. Being a Windows buff, I'd stick to PowerShell..
For Linux/Unix administration good shell scripting skills is essential. For more advanced automation, it is also good to know python, perl, or ruby. It really doesn't matter which you choose. Once you have become proficient with one, you will find that picking up the others to be an easy task.
Personally, ruby's package management system (gems) has always turned be off from using it from a scripting platform. Others hold different opinions and like it.
Pick one and dive in.
Some years ago I would have recommended to use PERL for things like that.
In my opinion it's always a good idea to have some base knowledge of shell scripting but if you really want to do something "bigger" use a script language (like Python, Ruby or Perl).
In meantime I see no reason to not use ruby for things like that. I really enjoy this language and you can do everything (?) that you could do in PERL in ruby as well (and you will have a real OO language at hand).
CPAN on the other hand is a quite nice argument to use PERL. Ruby gems are similar but I don't think there are that many gems as CPAN-modules available. But please compare by yourself (http://rubygems.org/).
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
We all know that Puppet and Chef are the superstars of the IT automation area, and they are developed in Ruby (though Chef 11 server was rewritten in Erlang).
In my working environment, a very large group of the operations team uses Python as the primary language to develop operation tools or basic system applications.
I want to find why both Puppet and Chef were written in Ruby? What are the advantages? Ruby supports DSLs well. Can Python do such thing?
From Luke Kanies, Puppet’s author:
I was a sysadmin by trade and had mostly developed in perl, but when I
tried to write the prototype I had in mind, I couldn’t get the class
relationships I wanted in perl. I tried Python, because this was
around 2003 and Python was the next new thing and everyone was saying
how great it is, but I just can’t seem to write in Python at all. A
friend had said he’d heard Ruby was cool, so I gave it a try, and in
four hours I went from never having seen a line of it to having a
working prototype. I haven’t looked back since then, and haven’t
regretted the choice.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I see that Ruby is a big success when it comes to web programming. However, for desktop applictions and scripts, I do not see it being heavily used. In fact, in most of the Linux distros, it does not come installed by default. Most applications are coded in Python and some are in Perl. What advantages can Ruby offer over Python when it comes to desktop applications and scrips? If i am writing one Linux application, say a music player, how Ruby blocks and metaprogramming techniques can help?
Edit:
I see that some have opted for close this question because it can escalate into a Language war, perhaps. Fear not, I am a day-time Python programmer. I am trying to reconcile these seemingly incompatible observations. It is fact that most Linux distros do not come with a ruby installed. It is also a fact that most Linux apps are coded in Python. And it is also a fact that Ruby has more advanced meta-programming features than Python, which can make development easier. I am wondering why Ruby is not used as much in Linux application development, which has been a playground for scripting languages.
Python has become popular on the Linux side because many distributions have built their various front-end tools using it so it's guaranteed to be available.
Ruby does have Qt bindings that might be what you're looking for and it's possible to write wrappers for any C or C++ library you need to interface with.
In the end it all comes down to finding a suitable example to learn from. You may find that there are far more Python examples to refer to and this may affect your decision.
Both languages are equally capable on the whole and the default distributions are similar in terms of performance. Python's new PyPy compiler is faster if you don't mind sticking to Python 2.7, and there's also Rubinius which is an effort to boost Ruby's performance.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Recently started work at a place that uses windows exclusively, and really could do with a simple shell that replicates bash functionality. MinGw and Cygwin seem overkill for what I need. Any suggestions gladly accepted.
Thanks
You don't have to install all of Cygwin, since you can select individual packages.
Having said that, I still prefer to install the lot simply because I would rather have all the tools handy when I need them, rather than having to go and figure out which packages they're in. Even if you install the lot, no-ones forcing you to use all of them and, let's face it, disk space is hideously inexpensive nowadays.
If you want individual binaries for things like grep, sed and awk, you can also look into GnuWin32 - these are native executables that don't require the Cygwin DLL. You can just choose the executables you want from the package list and they'll be installed for you.
A shell's functionality usually uses external programs. You can download the windows versions of the tools you want:
grep, awk, sed
You might also want to take a look into PowerShell - a windows shell that is actually good(much, much, much better than CMD), and has good interaction with the Windows environment.
Not exactly a shell, but I still use tools from the UnxUtils package, one of many tool sets which has ported little lightweight commands/apps/tools, ever so handy and useful in scripts.
Nowadays I am also exploring Powershell more and more, a shell certainly worth taking a look at. On Wikipedia's Powershell page one can even find a comparison of cmdlets with similar commands in Bash a.o., which you might find interesting.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Is still worth learning expect? Because I have not seen any new books on this topic? What would anyone recommend for a good book on this?
expect is best used for controlling scripts that output queries and require a response. Many other languages struggle with this and create deadlocks on stdin/stdout when trying to use both. Expect also overcomes some issues with password entry (like when scripting SSH).
Having said that it isn't necessary to know expect because many other languages have an expect module (tcl and python come to mind) which provide the same behaviour.
I would have to say it depends on your job. If you spend a lot of time interacting with repetitive commandline scripts or FTP then expect is well worth adding to your scripting arsenal.
SpliFF wrote above about "... interacting with repetitive commandline script or FTP ..." While I'm all for automation, and regard Expect as indispensable, Expect is NOT necessary in 2010 for FTP or many other roles where it once was necessary. Fifteen years ago, for example, Expect was an appropriate way to automate FTP; now, most scripting languages already build in capabilities sufficient to replace Expect's use with FTP. Many, many automations can be done with what Perl, Python, Tcl, ... already build in, and Expect is not essential for these applications.
It never hurts to have another tool in your kit. Expect really does fill its niche extremely well.
The quintessential Expect book is Exploring Expect. It's the only Expect book you need.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm digging around trying to find a good set of tools for creating console applications, as most of the settings I expect to be using Ruby in the coming months won't be webapps, but server-side scripts.
I know of highline, and I do plan on using that for user and possible password prompts, but I know that the Console application world should be chock-full of other gems to assist and/or enrich your plain 'ol command-line apps.
Does anyone have some good suggestions? I'm not exactly sure what I'm really looking for, but I wouldn't be surprised if there were gems in Ruby to help with colorizing, ascii-like art, user-interaction (similar to bash-completion), man-page similar tools (or generators) or just helpers for making the work of creating a richer console app not come across as being so difficult to understand, or plain and cryptic.
Here's some console related gems I've written you may like:
bond - Custom readline autocompletion of methods, arguments and more.
hirb - Framework for formatting ruby objects. Comes with tables, trees, selection menus and a smart pager.
alias - Creates, manages and saves aliases for class methods, instance methods, constants, delegated methods.
My table_print gem lets you see IRB output in easy-to-scan table format. Super simple, lightweight, customizable. http://tableprintgem.com