これを自動化したい。
一番ラクなのはwebから設定することであるが、cgiはそのままではシステムにかかわるファイルに追記したりサービスリスタートなどはできない。できては困る。権限がないのだ。
apacheでsudoを使うようにすればいいようだが、ひとつ困ったことがある。
cgiでファイルを open $fh,">>file.txt"; とやると、permission deniedになる。これは sudoでは解決しない。
ファイルをいじるスクリプトを作ってそれを呼ぶようにしないと駄目か。
# ps aux|grep ibus hoge 2260 6.0 0.2 148464 2332 ? Sl 07:00 0:04 /usr/bin/ibus-daemon -r --xim hoge 2268 0.0 0.3 158108 3336 ? S 07:00 0:00 /usr/libexec/ibus-gconf hoge 2272 0.0 0.6 235456 6232 ? S 07:00 0:00 /usr/libexec/ibus-x11 --kill-daemon root 2374 0.0 0.0 107460 924 pts/1 S+ 07:01 0:00 grep ibus # ibus-setup Traceback (most recent call last): File "/usr/share/ibus/setup/main.py", line 28, in <module> import gtk ImportError: No module named gtk
python /usr/share/ibus/ui/gtk/main.py python /usr/share/ibus-anthy/engine/main.py
python /usr/share/ibus/ui/gtk/main.py Traceback (most recent call last): File "/usr/share/ibus/ui/gtk/main.py", line 33, in <module> import ibus ImportError: No module named ibus
import os import sys import getopt #import ibus #import gtk import gettext #import panel #import pynotify
# cd /usr/lib/mozilla/plugins/ # ll 合計 0 # cd / # find -name "libflashplayer.so" ./usr/lib64/mozilla/plugins/libflashplayer.so ./usr/lib64/flash-plugin/libflashplayer.so # cp /usr/lib64/mozilla/plugins/libflashplayer.so /usr/lib/mozilla/plugins/
cpan[1]> install Net::Twitter::Lite CPAN: Storable loaded ok (v2.20) Going to read '/root/.cpan/Metadata' Database was generated on Fri, 25 Jan 2013 14:53:03 GMT CPAN: LWP::UserAgent loaded ok (v6.04) CPAN: Time::HiRes loaded ok (v1.9725) Fetching with LWP: ftp://ftp.riken.jp/lang/CPAN/authors/01mailrc.txt.gz CPAN: YAML loaded ok (v0.70) Going to read '/authors/01mailrc.txt.gz' CPAN: Compress::Zlib loaded ok (v2.058) ............................................................................DONE Fetching with LWP: ftp://ftp.riken.jp/lang/CPAN/modules/02packages.details.txt.gz Going to read '/modules/02packages.details.txt.gz' Database was generated on Sun, 27 Jan 2013 15:17:03 GMT .............. New CPAN.pm version (v1.9800) available. [Currently running version is v1.9402] You might want to try install CPAN reload cpan to both upgrade CPAN.pm and run the new version without leaving the current session. ..............................................................DONE Fetching with LWP: ftp://ftp.riken.jp/lang/CPAN/modules/03modlist.data.gz Going to read '/modules/03modlist.data.gz' ............................................................................DONE Going to write /root/.cpan/Metadata Net::Twitter::Lite is up to date (0.11002).
my $clip = Win32::Clipboard();
exit 1 unless $clip->IsText();
my $text = $clip->GetText();
$filename ='newwords.txt';
open $fh,'>>',$filename or die;
print $fh $text."\n";
close $fh;
[Sun Jan 27 04:48:27 2013] [error] [client xx.xx.xx.xx] PHP Fatal error: Class 'DOMDocument' not found in /var/www/html/wiki/includes/LocalisationCache.php on line 542,(以下略)
# yum install php-xml # yum install php-dom # service httpd restart
# rpm -qa|grep php php-mbstring-5.3.3-14.el6_3.x86_64 php-xml-5.3.3-14.el6_3.x86_64 php-common-5.3.3-14.el6_3.x86_64 php-pdo-5.3.3-14.el6_3.x86_64 php-gd-5.3.3-14.el6_3.x86_64 php-cli-5.3.3-14.el6_3.x86_64 php-mysql-5.3.3-14.el6_3.x86_64 php-devel-5.3.3-14.el6_3.x86_64 php-5.3.3-14.el6_3.x86_64 php-mcrypt-5.3.3-1.el6.x86_64 php-pear-1.9.4-4.el6.noarch # rpm -qa|grep mysql compat-mysql51-5.1.54-1.el6.remi.x86_64 mysql-5.5.28-3.el6.remi.x86_64 mysql-devel-5.5.28-3.el6.remi.x86_64 mysql-libs-5.5.28-3.el6.remi.x86_64 mysql-server-5.5.28-3.el6.remi.x86_64 php-mysql-5.3.3-14.el6_3.x86_64
use Mojolicious::Lite;
get '/' => 'index';
app->start;
__DATA__
@@ index.html.ep
Hello World!
C:\Users\t\mojo>morbo mojo.pl
[Sun Jan 27 04:09:27 2013] [info] Listening at "http://*:3000".
Server available at http://127.0.0.1:3000.
if($date =~ /(\d{4})(\d{2})(\d{2})/){
$yy = $1;
$mm = $2;
$dd = $3;
}
for($i=0; $i<=100; $i++){
if(($i % 15)==0){
print "Fizz Buzz\n";
}elsif(($i % 3)==0){
print "Fizz\n";
}elsif(($i % 5)==0){
print "Buzz\n";
}else{
print $i."\n";
}
}
$a = 99;
print $a."\n";
if($a > 10 and $a < 50 or $a == 99){
print "baaa\n";
}
$a = 99;
print $a."\n";
if((($a > 10) and ($a < 50)) or ($a == 99)){
print "baaa\n";
}
v ( --VISUAL-- モードになる)(カーソルをインデントしたい範囲の最後の行まで動かす)
>
<?php /** * @file * User has successfully authenticated with Twitter. Access tokens saved to session and DB. */ /* Load required lib files. */ session_start(); require_once('twitteroauth/twitteroauth.php'); require_once('config.php'); /* If access tokens are not available redirect to connect page. */ if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) { header('Location: ./clearsessions.php'); } /* Get user access tokens out of the session. */ $access_token = $_SESSION['access_token']; /* Create a TwitterOauth object with consumer/user tokens. */ $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']); /* If method is set change API call made. Test is called by default. */ $req1 = $connection->OAuthRequest("https://api.twitter.com/1.1/account/verify_credentials.json","GET"); $req2 = $connection->OAuthRequest("https://api.twitter.com/1.1/blocks/list.json","GET"); $json1 = json_decode($req1,true); $json2 = json_decode($req2,true); /* Include HTML to display on the page */ include('html.inc');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Twitter OAuth in PHP</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <style type="text/css"> img {border-width: 0} * {font-family:'Lucida Grande', sans-serif;} </style> </head> <body> <div> <h2>Welcome to a Twitter OAuth PHP example.</h2> <p>This site is a basic showcase of Twitters OAuth authentication method. If you are having issues try <a href='./clearsessions.php'>clearing your session</a>.</p> <p> Links: <a href='http://github.com/abraham/twitteroauth'>Source Code</a> & <a href='http://wiki.github.com/abraham/twitteroauth/documentation'>Documentation</a> | Contact @<a href='http://twitter.com/abraham'>abraham</a> </p> <hr /> <?php if (isset($menu)) { ?> <?php echo $menu; ?> <?php } ?> </div> <?php if (isset($status_text)) { ?> <?php echo '<h3>'.$status_text.'</h3>'; ?> <?php } ?> <p> <pre> <?php print_r($content); ?> <hr> <?php print($json1[screen_name])." is blocking <br><br>"; foreach($json2[users] as $key => $value){ print $value[screen_name].'<br>'; } ?> </pre> </p> </body> </html>