1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

さっきの投稿に.aurcとかって書いてあったので、これは何かというと

Last updated at Posted at 2012-03-15

こういうのを vim の保存時に引っかけてたんですね。

.aurc のレイアウト
1行目:user_name@hostname
2行目:/path/to/identity_file
3行目:リモートホストでのプロジェクトルート

aurc.pl
#!/usr/bin/perl
use strict;
my $target_file  = shift @ARGV;
my $command      = shift @ARGV;
$command or $command = 'UP';


if ( $target_file =~ /\.pl$|\.cgi$/ )    { 
  my $result = `perl -c $target_file 2>&1`;
  print $result;
  $result =~ /syntax ok/i or exit(0);
}
elsif ( $target_file =~ /\.php$|\.phtml$/ ) { 
  my $result = `php -l  $target_file 2>&1`;
  print $result;
  $result =~ /no syntax error/i or
    exit(0);
}

my $tmp         = $target_file;
my $host        = '';
my $identity    = '';
my $local_root  = '';
my $remote_root = '';

while ( $tmp =~ s#/[^/]+$## ){
  opendir DIR, $tmp;
  while ( my $fn = readdir ( DIR ) ){
    $fn eq '.aurc' or next;
    $local_root = $tmp;
    open F, $tmp . '/' . $fn;
    ( $host, $identity, $remote_root ) = <F>;
    chomp $host;
    chomp $identity;
    chomp $remote_root;
    last;
  }
  close DIR;
  $remote_root and last;
}
$remote_root     or die 'not found .aurc';

my $remote_file = $target_file;
$remote_file =~ s#$local_root##e;
$remote_root =~ s#/$##;
$remote_file =~ s#^/##;
$remote_file = $remote_root . '/' .$remote_file;

my $cmd = 'sftp ';
$identity and $cmd .= ' -oIdentityFile="' . $identity . '" ';
$cmd .= $host;
open  SFTP, '| ' . $cmd;

if ( $command eq 'UP' )  { print SFTP 'put "' . $target_file . '" "' . $remote_file . '"' . "\n"; } 
else                     { print SFTP 'get "' .  $remote_file. '" "' . $target_file . '"' . "\n"; }
print SFTP "quit\n";
close SFTP;
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?