Ruby on a Mac

HI,
I’m new to my Mac. I love it, but, it’s definitely different than the
PCs I used for 20 years.

I’ve got some simple Ruby scripts that worked fine on my PC, but, they
don’t seem to work on my Mac.

Here’s one below. All it does it to use “curl” to pull some graphics
files from a distant database. My shell command would be something like:
orcagets.rb im197941.pdf im197963.pdf

Below is “orcagets.rb”

#!/usr/bin/ruby
$orcafile1 = ARGV[0]
$orcafile2 = ARGV[1]

$url = “http://ps2000-graphics-prod.bna.com/view/

if $orcafile1 =~ /^p/ then
puts “This first file is a p file.”
$prefix =
$orcafile1[/^([A-z,0-9]{1,15}p)([0-9]{1,5}).([A-z]{3,4})/]
$prefix = $1
$numeral1 = $2
$flavor = $3
$numeral2 = $orcafile2[/^[A-z,0-9]{1,15}p([0-9]{1,5}).[A-z]{3,4}/]
puts $numeral2
if $flavor == “tif” then
$flavor = “tiff”
$extension = “tif”
end
for i in $numeral1…$numeral2
curl -o #{$prefix}0#{i}.#{$flavor} #{$url}#{$flavor}/#{$prefix}0#{i} if i.to_i < 10
curl -o #{$prefix}#{i}.#{$flavor} #{$url}/#{$flavor}/#{$prefix}#{i} if i.to_i > 9
end
else
$prefix = $orcafile1[/^([A-z]{1,5})([0-9]{1,6}).([A-z]{3,4})/]
$prefix = $1
$numeral1 = $2
$flavor = $3
$extension = $3
$numeral2 = $orcafile2[/^[A-z]{1,5}([0-9]{1,6}).[A-z]{3,4}/]
$numeral2 = $1
puts $numeral2
if $flavor == “tif” then
$flavor = “tiff”
$extension = “tif”
end
for i in $numeral1…$numeral2
curl -o #{$prefix}#{i}.#{$extension} #{$url}/#{$flavor}/#{$prefix}#{i}
end
end

I get, when I run the above script:

(LoadError)y: No such file or directory –

I have no problem on my PC. The files come over.

Thanks,
Peter

Seems like it can’t find curl. Try putting an explicit path in the
backticks. I tried just curl on my leopard box and it worked,
though…

On Sep 20, 2011, at 12:16 , Peter B. wrote:

Below is “orcagets.rb”

Holy random indenting batman! Could you please normalize your code
before you send it off for us to (try to) read?

https://gist.github.com/984dce8b30746dedade3

Here. Can’t reproduce your error, Peter. I’d suggest you look at your
environment, not at the script.

kaspar

HI,
I’m new to my Mac. I love it, but, it’s definitely different than the
PCs I used for 20 years.

I’ve got some simple Ruby scripts that worked fine on my PC, but, they
don’t seem to work on my Mac.

Here’s one below. All it does it to use “curl” to pull some graphics
files from a distant database. My shell command would be something like:
orcagets.rb im197941.pdf im197963.pdf

I notice you’re not really using curl for anything complicated, so it
seems more fitting to use the standard Net::HTTP backend instead. Here
is a GitHub repository someone put together with example usage:

https://github.com/augustl/net-http-cheat-sheet

The reason I recommend this is because you don’t have to worry about
whether or not a machine has curl, and you also don’t have to worry
about shell parameter escaping since you’re dealing with a remote host.

Regards,
Chris W.
Twitter: http://www.twitter.com/cwgem

Nation, Carey wrote in post #1022993:

Seems like it can’t find curl. Try putting an explicit path in the
backticks. I tried just curl on my leopard box and it worked,
though…

I get results from typing “curl” anywhere I am when I’m in terminal.

Kaspar S. wrote in post #1023054:

https://gist.github.com/984dce8b30746dedade3

Here. Can’t reproduce your error, Peter. I’d suggest you look at your
environment, not at the script.

kaspar

OK. I’ll poke around some more. Thanks.

Ryan D. wrote in post #1023001:

On Sep 20, 2011, at 12:16 , Peter B. wrote:

Below is “orcagets.rb”

Holy random indenting batman! Could you please normalize your code
before you send it off for us to (try to) read?

Well, I’m sorry, but, that’s how it goes in with a cut & paste from my
Ruby editor.

Peter B. wrote in post #1023079:

Kaspar S. wrote in post #1023054:

https://gist.github.com/984dce8b30746dedade3

Here. Can’t reproduce your error, Peter. I’d suggest you look at your
environment, not at the script.

kaspar

OK. I’ll poke around some more. Thanks.

Wow. I’m sorry. I found my problem. I’m so new to the Mac that I forgot,
when I saved my script in TextMate, to save it with Mac line endings. It
was still set to Windows. Sorry about that. Thanks for all your help,
everybody.

-Peter

I found my problem.

I think your code is a problem too. Too many $ where it seems useless.
And no method or class separation … it’s archaic programming similar
to BASIC. :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs