LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 08-06-2008, 12:53 PM   #1
wrapster
Member
 
Registered: May 2008
Posts: 155

Rep: Reputation: 30
Needed help in a ruby script with user interaction involved!


Hi all,

I am struck at this point and needed some help in ruby
I wanted to write a script that accepts the no of VNICs the user wants to create and
then ask for the name of each Vnic he wants
then use these names to create the corresponding Vnics

Eg: suppose that there are 2 Vnics to be created
Then the user should be asked for the names of these and upon entering the names the corresponding ones are created

PS: this is actually a part of the wrapper script that i am struck with!
The command to create the Vnic is already present(in solaris,Crossbow) i just need to know how to include the names provided by the user into the command so that the job is done!

Could anyone please help me
Thanks
 
Old 08-06-2008, 04:38 PM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
This looks like very basic programming and is much more related to Ruby than Solaris. Your question would have a better exposure in the Programming forum but you should at least show a starting piece of code. I'm afraid no one is willing to write this code for you from scratch.

Moreover, someone convinced you to use ruby instead of shell script which would have been the natural choice for this task. Why not asking that person to teach you the ruby basics ?
 
Old 08-06-2008, 10:47 PM   #3
wrapster
Member
 
Registered: May 2008
Posts: 155

Original Poster
Rep: Reputation: 30
ok
I did write the code myself(with some quirks)
If its of any help then here it is!!!!
Code:
#!/usr/bin/ruby

class Etherstub
   def initialize
      @estub ; @stub_name
      @vni
   end

def ether_create
    puts "enter the no of stubs you want"
    @estub = gets ;puts "Enter the names 1 by 1 "
    @estub.to_i.each do
         |@stub_name| ;@stub_name = gets
        end
        @estub.to_i.times { puts `/usr/sbin/dladm create-etherstub #{@stub_name}
` }
print "Stub created!!"
end
end

first = Etherstub.new
first.ether_create
The error am getting is that am able to create only one etherstub at a time!
even with the loop!

Finally for you question reagarding shell script or ruby!!
This is choosen to be written in ruby because this will be a wrapper that will use the underlying commands and there are a few more reasons.....

Anyway i will try my luck in the programming forum!!!
Thanks
 
  


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
[Ruby] Tar'ing or Zip'ing with ruby script lmcilwain Programming 2 01-19-2007 06:56 PM
shell script interaction sudhasmyle Linux - Software 1 12-08-2004 03:34 PM
Interaction in shell script sudhasmyle Programming 1 12-08-2004 07:27 AM
user interaction disabling? dafri Linux - General 2 07-20-2003 05:39 AM
fdisk without user interaction tiger Linux - Software 1 09-10-2001 02:06 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

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