A place where the Joyent community can gather, help each other out, and stay informed.
You are not logged in.
I applaud the decision to require SFTP only. However, I'll need to make an adjustment at my end to keep up. Our firewall at work does not admit SSH traffic, and our proxy is too primitive to understand WebDAV.
I need to get .ics files from my work PC to my TxD account on a regular basis.
Any suggestions?
The first idea that presents itself to me is to create a new alias in Webmin and select the "Feed to program" option. Does that choice mean I can just dump into my homedir an .rb file with the appropriate shebang inside it, parse out the .ics file from the e-mail, and save it in my ical directory? What does my script "see"? Is it the entire source of the mail in plain text? Does it come in on stdin?
Are there smarter alternatives to what I'm doing?
Thanks in advance for any ideas.
Offline
undees wrote:
Does that choice mean I can just dump into my homedir an .rb file with the appropriate shebang inside it, parse out the .ics file from the e-mail, and save it in my ical directory?
You can!
Is it the entire source of the mail in plain text? Does it come in on stdin?
Yes and yes.
Offline
In Python: http://textsnippets.com/posts/show/37
Offline
Brilliant. Thanks, Tim.
The Ruby version will appear in a subsequent post (with TMail installed in my home dir -- happy to hear of any better way to do this).
Still a couple of file permission issues to work out: the file is created owned by nobody:username. The only way for it to be available by WebDAV appears to be to give the file o+r permissions (e.g., 664). What user does WebDAV run? Is there a way for me to make my calendar file available via WebDAV without allowing any TxD user on my server to be able to read the file?
Offline
As promised, here's the Ruby version of the script.
#!/usr/local/bin/ruby
$: << '/home/username/usr/local/lib/ruby/site_ruby/1.8'
require 'tmail's = $stdin.read
if 'text/calendar' == part.content_type t = part.body t.gsub!(/=[\r\n]+/, '') t.gsub!(/=(\w\w)/) {$1.hex.chr} outPath = '/home/username/path/to/Calendar.ics' File.open outPath, 'w' do |f| f.write t end File.chmod 0664, outPath end
mail = TMail::Mail.parse s
mail.parts.each do |part|
end
Last edited by undees (2005-05-29 10:23:12)
Offline
tim wrote:
In Python: http://textsnippets.com/posts/show/37
Rock On!
Offline
undees wrote:
As promised, here's the Ruby version of the script.
The power of snippets:
Offline
Thanks for posting the snippet, Jason! Good to know that I can post there in the future if an idea possesses me and might be of use to others.
Do you have any advice for the WebDAV / permissions thing?
My latest thought was to go ahead and let the mail-triggered script save the file with 660 permissions (owned by nobody:undees, which I don't think I can control), and maybe kick off a cron job to copy this file once a day to a file fully owned by me. If a file is owned by undees:undees, can I give it restrictive permissions (660) and still see it via WebDAV?
Offline