The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
running script in cron - with ssh commands - not working frustrated1 Shell Programming and Scripting 31 09-16-2008 10:14 AM
pwd & cd commands not working in shell script perk_bud Shell Programming and Scripting 9 04-07-2008 07:11 AM
How to run unix commands in a new shell inside a shell script? hkapil Shell Programming and Scripting 2 01-04-2006 06:56 AM
differnce between working of at and crontab commands doddas UNIX for Dummies Questions & Answers 2 05-04-2005 03:17 PM
KORN Shell - Spawn new shell with commands frustrated1 Shell Programming and Scripting 2 04-20-2005 02:23 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-25-2008
wrapster wrapster is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 193
How to get shell commands working through ruby?

Hi all,

I am a newbie currently trying to execute shell commands from ruby instead of a shell script.(This method is conceived only for solaris so no issues with porting to other OS and all)
Eg:
Consider the command 'ls"
with a shell script ,I would use it like this
bash# ls
<all the contents in that dir would be displayed>

Now how do i get to do the same with ruby?

I dont want to use methods like recursively searching the directory and then displaying the contents(through some while loop )
It has to be only "ls", as in i need to make "ls" work on solaris through ruby as it would if it were to be written In a shell script?

Thanks
  #2 (permalink)  
Old 07-25-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,794
You can get the listing with ruby, why you want to use ls?

Code:
ruby -e'puts Dir["*"]'

Anyway ...

Code:
ruby -e'puts `ls`'
  #3 (permalink)  
Old 07-25-2008
wrapster wrapster is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 193
Actually ls was just an easy example that i mentioned.
I am actually improvising a few commands through ruby and since am a beginner i have very little idea of programming in ruby.
So just wanted to have an idea.
By the way can you guide me to any good tutorials for beginners

Thanks
  #4 (permalink)  
Old 07-25-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,794
Well,
I'm quite new to ruby too, but it's the next language in my personal list (after Perl). All I have for now is Practical Ruby for System Administration (available on Amazon). You can also check the resources listed at hypermetrics.com/rubyhacker/clrFAQ.html#tag12 .
  #5 (permalink)  
Old 10-05-2008
muasif80 muasif80 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 1
Using Shell Commands in Ruby

Linux Certification LPIC: Using Shell Commands in Ruby
Sponsored Links
Closed Thread

Bookmarks

Tags
linux commands, os command, ruby

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 08:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0