Professional Web Applications Themes

ARGV problems - Ruby

i seem to be having a problem with ARGV. something as simple as this: ARGV.each {|x| print "#{x}"} prints: %* regardless of how many arguments i use. what's the proper way of getting commandline arguments. i was hoping to keep the code down by not using getoptlong, but i'll use it if necessary -- http://home.cogeco.ca/~tsummerfelt1...

  1. #1

    Default ARGV problems

    i seem to be having a problem with ARGV.

    something as simple as this:


    ARGV.each {|x| print "#{x}"}

    prints: %*

    regardless of how many arguments i use.

    what's the proper way of getting commandline arguments. i was hoping to
    keep the code down by not using getoptlong, but i'll use it if necessary

    --
    http://home.cogeco.ca/~tsummerfelt1
    tony Guest

  2. #2

    Default Re: ARGV problems

    In article <HFQTb.1317$cgocable.net>,
    tony summerfelt <com> wrote: 

    Is that your entire code?

    [mikeratdog tmp]$ cat try.rb
    #!/usr/bin/env ruby

    ARGV.each {|x| puts "#{x}"}
    [mikeratdog tmp]$ ./try.rb foo bar baz
    foo
    bar
    baz
    [mikeratdog tmp]$

    Mike
    --
    co.uk | The "`Stok' disclaimers" apply.
    http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA
    com | Fingerprint 0570 71CD 6790 7C28 3D60
    http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA
    Mike Guest

  3. #3

    Default Re: ARGV problems

    Mike Stok wrote:
     [/ref]

    I would make a wild guess that you call your ruby script from a shell
    script trying to pass it all command line parameters the sell script has
    been called with. In a shell script $* stands for the entire command
    line, and it seems like you do %* instead.

    However if you use .bat files on Windows, where %* is a correct way to
    specify all parameters, than it beats me.

    Gennady.


    Gennady Guest

  4. #4

    Default Re: ARGV problems

    On Tue, 03 Feb 2004 at 19:27 GMT, Mike Stok <co.uk> wrote:
     
     


    yup.

    i AM using the new windows installer version of ruby (v1.8.1 (2004-01-07)
    that was just announced.

    [checking older version (2004-01-27)].

    ah ha...older version works fine...

    i'd guess there's something seriously wrong with the installer version :/


    --
    http://home.cogeco.ca/~tsummerfelt1
    tony Guest

  5. #5

    Default Re: ARGV problems

    On Tue, 03 Feb 2004 at 19:45 GMT, Gennady <com> wrote:
     


    this was all from the command line.


    on further investigation, my command shell is 4nt (nt version of 4dos) and
    just typing the program: argtest.rb aa bb

    using a batch file it ran ok.

    if i use the direct path to ruby g:\ruby\bin\ruby argtest.rb aa bb it
    works fine also...


    --
    http://home.cogeco.ca/~tsummerfelt1
    tony Guest

  6. #6

    Default Re: ARGV problems

    Hi,

    At Wed, 4 Feb 2004 07:15:04 +0900,
    tony summerfelt wrote: 

    Do you associate .rb to "g:\ruby\bin\ruby.exe %0 %*"? If so,
    does 4nt really expand %* in associated command lines?

    --
    Nobu Nakada


    nobu.nokada@softhome.net Guest

  7. #7

    Default Re: ARGV problems

    On Tue, 03 Feb 2004 at 23:38 GMT, <net> wrote:
     

    yes, actually i use .rb="g:\ruby\bin\ruby.exe" and i had a typo

    now of course it works :/

    that should be the last of the dumb questions i ask...for awhile.. :)

    --
    http://home.cogeco.ca/~tsummerfelt1
    tony Guest

Similar Threads

  1. argv/argc problems in win2k
    By Tom in forum PHP Development
    Replies: 2
    Last Post: December 23rd, 03:58 PM
  2. ARGV
    By John Dillon in forum PERL Beginners
    Replies: 2
    Last Post: September 30th, 06:47 PM
  3. Recall: ARGV
    By John Dillon in forum PERL Beginners
    Replies: 0
    Last Post: September 30th, 10:06 AM
  4. module and $ARGV help
    By James Willmore in forum PERL Miscellaneous
    Replies: 3
    Last Post: July 27th, 06:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139