Thanks Jamis & David, I was able to make upload() work. @David I
could do the build as you suggest, but my first goal is to script the
existing process before making big changes to it. I like to do
anything that touches production in very small steps.
Here are some notes on behavior I discovered on the way; they may be
specific to my systems (local is a Mac running Tiger, remote is a
CentOS box running a 2.6 kernel). But I guess not, because most of
the capistrano failures worked when I did the uploads using sftp
directly.
* neither the default sftp nor the alternate scp can handle a local
filename starting with a ~ character, like so:
upload( "~/dist/test.jar", "test.jar" )
upload( "~/dist/test.jar", "test.jar", :via => :scp )
sftp produces this error:
/Library/Ruby/Gems/1.8/gems/capistrano-2.4.0/lib/capistrano/
transfer.rb:156:in `[]=': undefined method `[]=' for nil:NilClass
(NoMethodError)
scp just can't find the file.
No such file or directory - ~/dist/test.jar
* using sftp, you must name the remote file, whereas with scp you can
just indicate the current directory:
upload( "dist/test.jar", "." ) # sftp does not like the .
upload( "dist/test.jar", "./somedir/" ) # can't open it
upload( "dist/test.jar", "somedir/" ) # can't open it
upload( "dist/test.jar", "somedir" ) # can't open it
upload( "dist/test.jar", ".", :via => :scp ) # works
upload( "dist/test.jar", "./somedir/", :via => :scp ) # works
upload( "dist/test.jar", "somedir/", :via => :scp ) # works
upload( "dist/test.jar", "somedir", :via => :scp ) # works
upload( "dist/test.jar", "somedir/test.jar" ) # works
* using scp, you can specify ~/ as the remote directory; using ftp
this fails
upload( "dist/instruct.jar", "~/" ) # sftp does not like the twiddle
# upload via sftp failed on edison: Net::SFTP::StatusException
(Net::SFTP::StatusException open . (4, "failure"))
upload( "dist/instruct.jar", "~/", :via => :scp ) # works
* probably the most common case, however, works just fine with both
methods.
upload( "dist/instruct.jar", "instruct.jar" ) # works
upload( "dist/instruct.jar", "instruct.jar", :via => :scp ) # works
Rachel
On Jun 23, 2:28 pm, Jamis Buck <[EMAIL PROTECTED]> wrote:
> The upload() helper is definitely what you want. Basically, you just
> give it the local file name and the remote file name, and it does the
> upload via SFTP:
>
> upload("/path/to/local.war", "/path/to/remote.war")
>
> If you want to use SCP instead:
>
> upload("local.war", "remote.war", :via => :scp)
>
> You can also use it to upload entire directory trees (though it is
> definitely faster to just archive the directory and upload the archive):
>
> upload("/local/dir", "/remote/dir")
>
> - Jamis
>
> On Jun 23, 2008, at 3:18 PM, rachel wrote:
>
>
>
> > On Jun 23, 2:09 pm, "David Masover" <[EMAIL PROTECTED]> wrote:
> >> On Mon, Jun 23, 2008 at 3:55 PM, rachel <[EMAIL PROTECTED]> wrote:
> >> The specific thing I'm trying to do is upload a file. I found put()
>
> >>> which seems to require a string parameter,
>
> >> How big is your file? You could always do a hack like:
>
> >> put File.read('/my/file'), '/some/where'
>
> > It's the application WAR file. It's big, and also a binary.
>
> >> There's also this blog post, somewhat outdated:
>
> >>http://devblog.famundo.com/articles/2007/03/10/improving-
> >> capistranos-...
>
> >> It looks like there is now an undocumented 'upload' method. That's
> >> probably
> >> better, if you can figure out how it works.
>
> > I will poke around at these options, thanks for the info. upload()
> > does sound like what I want, at least from the name!
>
> > thx,
> > Rachel
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---