From: ara.t.howard@... Date: 2006-10-25T13:47:46+09:00 Subject: Re: Best way to automate web browser tasks? On Wed, 25 Oct 2006, Hal Fulton wrote: > ara.t.howard@noaa.gov wrote: >> >> curl? >> >> seriously - do you have to do it via firefox? >> > > No, I *don't* have to do it via FF or any other browser. > > Can curl do that sort of thing? I've never used it > except for simple sucking-down of pages. > > Hal that, and then some. here's a script i use to post to sciruby: #! /usr/bin/env ruby $VERBOSE = nil # # built-in # require "getoptlong" # # setup # uri = "http://sciruby.codeforpeople.com/sr.cgi" moin_id = ENV['SCIRUBY_MOIN_ID'] # # options # opts = {} GetoptLong::new( [ "--moin_id", "-m", GetoptLong::REQUIRED_ARGUMENT ] ).each{|opt, arg| opts[opt.delete("-")] = arg} moin_id = opts["moin_id"] || ENV["MOIN_ID"] || moin_id # # argv # page, infile = ARGV.shift, ARGV.shift # # run # abort "#{ $0 } page [infile or stdin] [--moin_id=moin_id]" unless page page = "http://sciruby.codeforpeople.com/sr.cgi/#{ page }" unless page =~ %r/^http/ data = (infile.nil? or infile == "-") ? STDIN.read : open(infile){|f| f.read} command = <<-sh curl "#{ page }" \ -s -S --stderr - \ -bMOIN_ID=#{ moin_id } -A=Mozilla/4.0 \ -F action=savepage -F comment=curl -F "savetext=<-" sh command = command.strip.split(%r/\s+/).join(" ") STDERR.puts command IO::popen("#{ command }", "r+") do |pipe| pipe.puts data pipe.close_write while((line = pipe.gets)) print line end end abort "command <#{ command }> failed with <#{ $?.inspect }>" unless $? == 0 you might also consider http-access2, here's an example http://codeforpeople.com/lib/ruby/rubyforge/rubyforge-0.1.1/bin/rubyforge nearly all of what you need to know is at the begining or the very end. cheers. -a -- my religion is very simple. my religion is kindness. -- the dalai lama