Forum: Ruby RUBY keeps complaining about my "end" statement

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
351c78a440ea1743724968ddbae3f9aa?d=identicon&s=25 Peter B. (peterbailey)
on 2006-06-13 22:06
When I try and run a script that has this as part of it, RUBY keeps
complaining about my "end" statement. Can someone please help me with
this? What's its problem with it?

Thanks.



ps2kfiles =
Dir.glob("{aacmc7,acm059,acm061,acmc59,acmt59,adc064,adm064,cbncc7,
cgmpr,cpslit,cpsmco,edc131,edt131,eeomc7,emgc15,hcc201,hcci01,hct201,hcti01,
hla020,hlai20,hlb020,hlbi20,hltc20,hlti20,ierc78,itc101,jsc047,lrc013,lrfl21,
lrnm21,lrrc21,lrrc22,lrrc24,lrrc37,lrrc49,lrrc74,lrrmc6,lrrt37,mopc68,mopd68,
mopec8,mopt68,pgc117,pslc45,psvc45,rt013,rtc129,uln007}*.pdf")
ps2kfiles.each do |ps2kfile|
	ftp = Net::FTP.open('quark.bna.com')
	ftp.login('pb4072','retep1')
	ftp.chdir('/home/pb4072')
	#ftp.chdir('/prod/data/pdf/index-wip')
	ftp.putbinaryfile(#{ps2kfile})
end
Logan Capaldo (Guest)
on 2006-06-13 22:16
(Received via mailing list)
On Jun 13, 2006, at 4:06 PM, Peter Bailey wrote:

> 	ftp.putbinaryfile(#{ps2kfile})

Someone forgot quotes around his string interpolation. Of course its
not really needed here

ftp.putbinaryfile(ps2kfile)
Leslie Viljoen (Guest)
on 2006-06-13 22:16
(Received via mailing list)
On 6/13/06, Peter Bailey <pbailey@bna.com> wrote:
> cgmpr,cpslit,cpsmco,edc131,edt131,eeomc7,emgc15,hcc201,hcci01,hct201,hcti01,
> hla020,hlai20,hlb020,hlbi20,hltc20,hlti20,ierc78,itc101,jsc047,lrc013,lrfl21,
> lrnm21,lrrc21,lrrc22,lrrc24,lrrc37,lrrc49,lrrc74,lrrmc6,lrrt37,mopc68,mopd68,
> mopec8,mopt68,pgc117,pslc45,psvc45,rt013,rtc129,uln007}*.pdf")
> ps2kfiles.each do |ps2kfile|
>         ftp = Net::FTP.open('quark.bna.com')
>         ftp.login('pb4072','retep1')
>         ftp.chdir('/home/pb4072')
>         #ftp.chdir('/prod/data/pdf/index-wip')
>         ftp.putbinaryfile(#{ps2kfile})

Just staring at it, perhaps you meant:
ftp.putbinaryfile("#{ps2kfile}")


Les
Joel VanderWerf (Guest)
on 2006-06-13 22:19
(Received via mailing list)
Peter Bailey wrote:
> 	ftp.putbinaryfile(#{ps2kfile})

ruby is interpreting the # as a comment, since it's not within a string.
Try this:

   	ftp.putbinaryfile(ps2kfile)
Anton 'tony' Bangratz (Guest)
on 2006-06-13 22:20
(Received via mailing list)
Peter Bailey wrote:

> cgmpr,cpslit,cpsmco,edc131,edt131,eeomc7,emgc15,hcc201,hcci01,hct201,hcti01,
> hla020,hlai20,hlb020,hlbi20,hltc20,hlti20,ierc78,itc101,jsc047,lrc013,lrfl21,
> lrnm21,lrrc21,lrrc22,lrrc24,lrrc37,lrrc49,lrrc74,lrrmc6,lrrt37,mopc68,mopd68,
> mopec8,mopt68,pgc117,pslc45,psvc45,rt013,rtc129,uln007}*.pdf")
> ps2kfiles.each do |ps2kfile|
> 	ftp = Net::FTP.open('quark.bna.com')
> 	ftp.login('xxx','xxx')
> 	ftp.chdir('/home/xxx')
> 	#ftp.chdir('/prod/data/pdf/index-wip')
> 	ftp.putbinaryfile(#{ps2kfile})

ITYM:
	ftp.putbinaryfile(ps2kfile)
> end
>

Explanation: you do not need interpolation here, the variable
'ps2kfile' does hold the value you want already.

Oh, and you might want to change your password(s), if they are real.

HTH,

t.
351c78a440ea1743724968ddbae3f9aa?d=identicon&s=25 Peter B. (peterbailey)
on 2006-06-14 14:58
Logan Capaldo wrote:
> On Jun 13, 2006, at 4:06 PM, Peter Bailey wrote:
>
>> 	ftp.putbinaryfile(#{ps2kfile})
>
> Someone forgot quotes around his string interpolation. Of course its
> not really needed here
>
> ftp.putbinaryfile(ps2kfile)

You're absolutely right. I put quotes in and it worked. But, I don't
quite get it. I don't remember having to put them in before. Whatever .
. .

Thanks!
351c78a440ea1743724968ddbae3f9aa?d=identicon&s=25 Peter B. (peterbailey)
on 2006-06-14 15:01
Leslie Viljoen wrote:
> On 6/13/06, Peter Bailey <pbailey@bna.com> wrote:
>> cgmpr,cpslit,cpsmco,edc131,edt131,eeomc7,emgc15,hcc201,hcci01,hct201,hcti01,
>> hla020,hlai20,hlb020,hlbi20,hltc20,hlti20,ierc78,itc101,jsc047,lrc013,lrfl21,
>> lrnm21,lrrc21,lrrc22,lrrc24,lrrc37,lrrc49,lrrc74,lrrmc6,lrrt37,mopc68,mopd68,
>> mopec8,mopt68,pgc117,pslc45,psvc45,rt013,rtc129,uln007}*.pdf")
>> ps2kfiles.each do |ps2kfile|
>>         ftp = Net::FTP.open('quark.bna.com')
>>         ftp.login('pb4072','retep1')
>>         ftp.chdir('/home/pb4072')
>>         #ftp.chdir('/prod/data/pdf/index-wip')
>>         ftp.putbinaryfile(#{ps2kfile})
>
> Just staring at it, perhaps you meant:
> ftp.putbinaryfile("#{ps2kfile}")
>
>
> Les

Yes, that worked. Thank you. I don't know why it needs the quotes, but,
I'll accept  it.
351c78a440ea1743724968ddbae3f9aa?d=identicon&s=25 Peter B. (peterbailey)
on 2006-06-14 15:03
Anton 'tony' Bangratz wrote:
> Peter Bailey wrote:
>
>> cgmpr,cpslit,cpsmco,edc131,edt131,eeomc7,emgc15,hcc201,hcci01,hct201,hcti01,
>> hla020,hlai20,hlb020,hlbi20,hltc20,hlti20,ierc78,itc101,jsc047,lrc013,lrfl21,
>> lrnm21,lrrc21,lrrc22,lrrc24,lrrc37,lrrc49,lrrc74,lrrmc6,lrrt37,mopc68,mopd68,
>> mopec8,mopt68,pgc117,pslc45,psvc45,rt013,rtc129,uln007}*.pdf")
>> ps2kfiles.each do |ps2kfile|
>> 	ftp = Net::FTP.open('quark.bna.com')
>> 	ftp.login('xxx','xxx')
>> 	ftp.chdir('/home/xxx')
>> 	#ftp.chdir('/prod/data/pdf/index-wip')
>> 	ftp.putbinaryfile(#{ps2kfile})
>
> ITYM:
> 	ftp.putbinaryfile(ps2kfile)
>> end
>>
>
> Explanation: you do not need interpolation here, the variable
> 'ps2kfile' does hold the value you want already.
>
> Oh, and you might want to change your password(s), if they are real.
>
> HTH,
>
> t.

That worked. And, it is simpler. It's not a string, anyway, so, why
would I need the #{}s, right? Thank you! No, those aren't my
credentials. That's a fake password and credentials.
This topic is locked and can not be replied to.