Ubuntu 16.04 ftpクライアントツールをインストール
filezillaをインストールしてみた
google filezilla ubuntu install
参考
最新版のリポジトリを追加
sudo add-apt-repository ppa:sicklylife/filezilla
インストール
sudo apt update sudo apt install filezilla
実行
filezilla
無事、インストールができました。
Ubuntu 16.04 ftpクライアントツールをインストール
filezillaをインストールしてみた
google filezilla ubuntu install
参考
最新版のリポジトリを追加
sudo add-apt-repository ppa:sicklylife/filezilla
インストール
sudo apt update sudo apt install filezilla
実行
filezilla
無事、インストールができました。
Ubuntu 16.04
で、Mysqlクライアントソフトとして
Windows版の
HeidisqlをWineにてインストールしてみた。
Ubuntu 14.04
の場合と同じように使うことができた。
と同じ内容であるが、手順は以下となります。
Wineのインストール
https://symfoware.blog.fc2.com/blog-entry-1400.html
を、参考にする
sudo apt-get install wine
インストール中に
ttf-mscorefonts-installerの設定
が表示された時には
タブキーにて「了解」を選択しエンターキーを入力。
インストールが完了したら
winecfg
で、インストールされたWineのバージンを確認
「Wineについて」のタブを開く
1.6.2
HeidiSQL
をダウンロード
10.xx.xx
だと、起動しなかったので、
9.3.0.4984
https://heidisql.jp.uptodown.com/windows/download/429381
を、ダウンロード
ダウンロードしたものを、右クリックでWine Windows プログラムローダで開く
一度、インストールして、競合し、不具合になる時は
フォルダーを削除
sudo find ./ -name “Heidi*”
./.wine/drive_c/users/Public/Start Menu/Programs/HeidiSQL
あたり。
予約設定時間になった時に処理をする仕組みを作ってみる
環境
Ubuntu16
Lazarus 2.0.10
参考ページ
https://www.ipentec.com/document/delphi-get-now-datetime
https://www.ipentec.com/document/delphi-datetime-to-string
http://mrxray.on.coocan.jp/Delphi/plSamples/004_TimerTest.htm
ポイント
・現時刻を書式設定で文字列に変換
・タイマーで、毎回(2秒毎に)チェックを行う
・状態変数を持ち、変化時のみにイベント処理をできるようにする
プログラム
private
fltime:integer;
procedure TForm1.Button1Click(Sender: TObject);
//https://www.ipentec.com/document/delphi-get-now-datetime
//https://www.ipentec.com/document/delphi-datetime-to-string
//http://mrxray.on.coocan.jp/Delphi/plSamples/004_TimerTest.htm
var
dt:TDateTime;
str:string;
begin
dt:=Now;
DateTimeToString(str, 'HH:mm',dt);
Edit2.Text:=str;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
edit3.Text:=Combobox1.Text+':'+Combobox2.Text;
end;
procedure TForm1.ComboBox2Change(Sender: TObject);
begin
ComboBox1Change(Sender);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
fltime:=0;
combobox1.ItemIndex:=0;
combobox2.ItemIndex:=0;
ComboBox1Change(Sender);
timer1.Enabled:=True;
timer1.Interval:=2000; //2000ミリ秒(2秒)ごとに処理を行う
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Button1Click(Sender);
if edit3.Text=edit2.Text then
begin
if fltime=0 then
begin
MessageDlg('メッセージ', mtInformation, [mbYes], 0);
fltime:=1;
end;
end
else
fltime:=0;
end;
設定(初期設定)
Combobox1
00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23
Combobox2
00,05,10,15,20,25,30,35,40,45,50,55
を、
オブジェクトインスペクタ
プロパティ
Items
Stringエディタから
初期値を設定
Lazarusコンボボックスの初期値設定
時間設定のコンボボックスを作成してみた
初期値として
時間(0から23)と分(0から55分で5分刻み)
をセットする
時間
00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23
分
00,05,10,15,20,25,30,35,40,45,50,55
とする。(文字列)
まず、2つのコンボボックスを作り
オブジェクトインスペクタ
プロパティ
Items
Stringエディタから
初期値を入れることができた
Lazarus で、リストデータの移動処理を行ってみた
リストデータの受け渡しのための
データの移動追加の処理を行ってみた
環境
Ubuntu16
Lazarus 2.0.10
参考ページ
https://www.migaro.co.jp/contents/products/delphi400/tips/introduction/4_20/02/01.html
http://delfusa.main.jp/delfusafloor/archive/www.nifty.ne.jp_forum_fdelphi/faq/00055.htm
https://www.migaro.co.jp/contents/products/delphi400/tips/introduction/4_20/02/01.html
http://dp25299446.lolipop.jp/delphi_tips/tips0045.html
ポイント
リストにはListBoxを使う
・項目追加
ListBox.Items.Add(文字列)
・項目削除
ListBox.Items.Delete(番号);
選択している行の場合
ListBox.Items.Delete(ListBox.ItemIndex);
・選択しているデータ
ListBox1.Items[ListBox.ItemIndex]
・選択しているかの判断
if (ListBox.ItemIndex > -1) Then 選択されている else 選択されていない
・データの永続的処理(ロード、セーブ)
ListBox.Items.LoadFromFile(ファイル名);
ListBox.Items.SaveToFile(ファイル名);
・その他論理演算
等しい時 =
等くない時 <>
論理and and
プログラム
procedure TForm1.FormCreate(Sender: TObject);
begin
Button1.Caption:='>';
Button2.Caption:='<';
Button4.Caption:='adddata';
Button5.Caption:='delete';
Button6.Caption:='save';
Button3.Visible:=False;
ListBox1.Items.Add('abc-1');
ListBox1.Items.Add('abc-2');
ListBox1.Items.Add('abc-3');
Button3Click(Sender);
if FileExists('listdata.txt') then
ListBox2.Items.LoadFromFile('listdata.txt');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox2.Items.Add(ListBox1.Items[ListBox1.ItemIndex]);
ListBox1.Items.Delete(ListBox1.ItemIndex);
Button3Click(Sender);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ListBox1.Items.Add(ListBox2.Items[ListBox2.ItemIndex]);
ListBox2.Items.Delete(ListBox2.ItemIndex);
Button3Click(Sender);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if (ListBox1.ItemIndex > -1) and (ListBox1.Items.Count <> 0) then
button1.Enabled := True
else
button1.Enabled := False;
if (ListBox2.ItemIndex > -1) and (ListBox2.Items.Count <> 0) then
begin
button2.Enabled := True;
button5.Enabled := True;
end
else
begin
button2.Enabled := False;
button5.Enabled := False;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
ListBox2.Items.Add(edit2.Text);
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
ListBox2.Items.Delete(ListBox2.ItemIndex);
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
ListBox2.Items.SaveToFile('listdata.txt');
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
if edit2.text <> '' then
button4.Enabled := True
else
button4.Enabled := False;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
edit1.Text:=ListBox1.Items[ListBox1.ItemIndex];
Button3Click(Sender);
end;
procedure TForm1.ListBox2Click(Sender: TObject);
begin
Button3Click(Sender);
end;
Ubuntu16Desktopの英語環境でセットアップした所
Lazarusが英語環境となっていた
Ubuntu16Desktopの環境を
日本語環境に切り替えてた所
Lazarusも日本語環境になった
メニューなどが、日本語となっている
プログラムへの日本語入力はできないので
メモなどで日本語を打ち
コピペする必要がある
Conoha Ubuntu16Desktop日本語化にしてみました
参考
https://www.server-world.info/query?os=Ubuntu_20.04&p=japanese
https://qiita.com/myalpine/items/fb45b222924b2e61ea9f
右上の歯車の
System Settings..
から
LanguageSupport
「install/Remove Language..」
を選択
Japanes
を選択し
「Apply」
再起動をして有効にする
再起動は
ttps://eng-entrance.com/linux-ubuntu-reboot
を、参考に
右上のShutdownを選択した後に
Rebootを選択する
LazarusからShellを起動してみました
環境
Ubuntu16
Lazarus 2.0.10
ポイント
TProcessからShellを起動
Shellの完了待ちとする方法と、完了待ちしない方法を選択できます
参考ページ
https://wiki.freepascal.org/Executing_External_Programs
https://stackoverflow.com/questions/26977422/execute-commands-in-the-linux-commandline-lazarus-free-pascal
設定
uses
,Process; //追加
プログラム
procedure TForm1.Button1Click(Sender: TObject); var AProcess: TProcess; begin AProcess := TProcess.Create(nil); AProcess.CommandLine:='/bin/bash /home/user/xxx/test02.sh'; AProcess.Options := AProcess.Options + [poWaitOnExit]; AProcess.Execute; AProcess.Free; button1.Caption:='ok'; end;
以下をなくすと、完了を待たずに次のステップに進みます。
AProcess.Options := AProcess.Options + [poWaitOnExit];
test02.shの例
動作確認用
#!/bin/bash cd /home/user/xxx/ ls >> /home/user/xxx/log01.txt
Python起動例
#!/bin/bash source /home/user/env/bin/activate cd /home/user/xxx/ python test.py deactivate
環境
Ubuntu16
Lazarus
1.8.2 から 2.0.1へバージョンアップしてみました
sudo dpkg -i fpc-src_3.2.0-1_amd64.deb sudo dpkg -i fpc-laz_3.2.0-1_amd64.deb sudo dpkg -i lazarus-project_2.0.10-0_amd64.deb
の順で上書きを試みる
sudo dpkg -i fpc-laz_3.2.0-1_amd64.deb
失敗。fpc の削除 を処理できません (–auto-deconfigure を使いましょう):
lazarus-project は fpc (>= 3.0.4) | fp-utils (>= 3.0.4) に依存 (depends) します
fpc は削除されようとしています。
fp-utils はインストールされていません。
とでたので
sudo dpkg -i --auto-deconfigure fpc-laz_3.2.0-1_amd64.deb
startlazarus
で起動する
UPGRADEのメッセージが表示され指示に従うと
2.0.1へバージョンアップできた。
Ubuntu16 でCronを使ってみる
定期的にプログラムを実行する仕組みを
Cronで行ってみる
参考
まず、確認用の実行プログラムを作る
ファイル名
test.sh
内容
#!/bin/bash cd /home/userA/test/ ls >> log01.txt
権限を設定
$ chmod 755 test.sh
動作を確認
/bin/bash test.sh
Cronのファイルを複写する
cron_01というファイル名でコピーしています。
$ sudo cp /etc/crontab /etc/cron.d/cron_01
ファイルを編集する
$ sudo vim /etc/cron.d/cron_01 / スケジュールを追加する(1分ごとに起動) */1 * * * * ubuntu /bin/bash /home/userA/test/test.sh cronの再起動を行います。(既に起動済の場合は不要) sudo service cron restart
ファイル
log01.txt
が、追加されているか確認する
削除する場合は
/etc/cron.d/cron_01
を、編集(コメントアウト、削除)
Pythonプログラムを起動する場合
起動するスクリプトを変更
test.sh
#!/bin/bash source /home/user/env/bin/activate cd /home/user/test python test.py deactivate
test.pyの例
(フォルダーに時間指定のファイル名を出力する)
import time
import datetime
def main():
html='logdata'
now = datetime.datetime.now()
fname = now.strftime('%Y%m%d%H%M%S' + '_01.txt') # => '2019-08-02 02:20:43'
with open("log/" + fname, "w") as f:
f.write(html)
main()
動作確認を行っておくコマンドラインから
/bin/bash test.sh
動作確認ができたら
/etc/cron.d/cron_01
を、編集し、起動するようにする