Cloud term what does SaaS mean?

What is SaaS?

SaaS is an abbreviation of “Software as a Service”.

Refers to software provided in the cloud. Instead of installing the software on the user side, the vendor (provider) side runs the software, and the user leverages the functionality of the software via the network. Can think of what has been sold as packaged products up to now as available via the Internet.

Examples include email services such as Gmail, blog services, and services such as Salesforce. It is is useful in the sense that you can achieve the purpose immediately, but if you have low degrees of freedom and you want to use your own program, you need to use PaaS or IaaS as described.

grep -V

The -V option is used to search for non-matching ones.

[vagrant@localhost ses]$ grep gmail sendmail.cgi
$to = ‘hoge@gmail.org’;
[vagrant@localhost ses]$ grep -v print sendmail.cgi

なるほど、一致しないものね。使い勝手がいいですね。

perl use constant

Allow declaration of constants at compile time.

use constant PI => 4 * atan2(1, 1);
use constant DEBUG => 0;

print "Pi equals ", PI, "...\n" if DEBUG;

use constant{
	SEC => 0,
	MIN => 1,
	HOUR => 2,
	MDAY => 3,
	MON => 4,
	YEAR => 5,
	WDAY => 6,
	YDAY => 7,
	ISDST => 8,
};

use constant WEEKDAYS => qw(
	Sunday Monday Tuesday Wednesday Thursday Friday Saturday
);

print "Today is ", (WEEKDAYS)[ (localtime)[WDAY]], ".\";

Dovecot

Dovecot is an IMAP and POP3 server that runs on Unix-like operating systems. It is designed and developed with security system in mind, and is developed and released by Timo Sirainen etal.

perl sendmail

#!/usr/bin/perl

require 'getformdata.pl';

# sendmailパス
$sendmail = '/usr/sbin/sendmail';

# フォームデータの取得
%form = plab::getformdata();

# 個々の変数にコピー
$name = $form{'name'};
$from = $form{'from'};
$subject = $form{'subject'};
$message = $form{'message'};

# メールの送信先は固定
$to = 'hoge@gmail.org';

# Fromメールアドレスが空だとエラーになるので、
# 空なら仮に送信先アドレスを入れる
if($from eq ""){
	$from = $to;
}

# sendmailを書き込みオープンする
if(! open(MAIL, "|$sendmail -t")){
	# sendmailの起動ができませんでした
	print "Content-type: text/html\n";
	print "\n";
	print "メール送信に失敗しました。";

	# CGI終了
	exit;	
}

# チェック
$name =~ s/\r|\n//g;
$from =~ s/\r|\n//g;
$to =~ s/\r|\n//g;
$subject =~ s/\r|\n//g;

# ヒアドキュメントを作る
$mailtext = <<"EOM";
From: $name<$from>
To: <$to>
Subject: $subject
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="ISO-2022-JP"

$message
EOM

# パイプを通してsendmailにデータを渡す
print MAIL $mailtext;

close MAIL;
print "Content-type: text/html\n";
print "\n";
print "メールを送信しました。ありがとうございました";

exit;

sendmailはperlと関係なくメール送信プログラム

npm install aws-sdk –save

npm install の–saveオプションって何?
-> パッケージをインストールして、package.jsonに書き込む

[vagrant@localhost ses]$ npm -v
6.1.0
[vagrant@localhost ses]$ npm install aws-sdk –save
npm WARN saveError ENOENT: no such file or directory, open ‘/home/vagrant/local/app/test/package.json’
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open ‘/home/vagrant/local/app/test/package.json’
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README data
npm WARN test No license field.

+ aws-sdk@2.487.0
added 39 packages from 85 contributors, removed 30 packages, updated 1 package and audited 52 packages in 30.333s
found 0 vulnerabilities
あれ、package.jsonがないです。

AWS credentialsを設定し、メール送信する

var AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});

var ses = new AWS.SES();

var params = {
	Destination: {
		ToAddresses: [ 'hoge@example.com' ]
	},
	Message: {
			Body: {
				Text: {
						Data: 'hello SES',
						Charset: 'utf-8'
				}
			},
			Subject: {
				Data: 'Hello',
				Charset: 'utf-8'
			}
	},
	Source: 'jiro@example.com'
};

ses.sendEmail(params, function(err, data){
	if(err) console.log(err, err.stack);
	else console.log(data);
});

jsonか。。

mkdir ${dirname} && cd $_

コマンドラインで「$_」は一つ前の引数

[vagrant@localhost test]$ echo  hoge && echo $_
hoge
hoge

$_でhogeを引っ張てきている
mkdirでやると、

[vagrant@localhost test]$ mkdir ses && cd $_
[vagrant@localhost ses]$

おお、なんか素晴らしいですね。