VirtualBoxを利用してubuntuを起動した際に、とある実行ファイルを実行したいのですがうまくできません。
試した方法は
・rc.localから実行
・.config/autostart/gnome-terminal.desktopを利用してターミナル経由で起動
の2つです。
実行したいファイルは以下のように、
ただ「Hello World」を表示のと、ファイル出力するだけの簡単なコンソールアプリです。
C言語
1#include <stdio.h> 2#include <stdlib.h> 3int main(void) 4{ 5printf("Hello World!\n"); 6 7FILE *fp; 8fp = fopen("test.text", "w"); 9fprintf(fp, "Hello World!\n"); 10fclose(fp); 11 12return 0; 13}
これらのファイルのルートは
"/home/name/Test/"
となっており、Testディレクトリの中身は
/hello.c
/a.out
のみとなっております。
rc.localで行った際は
rc.local
1#!/bin/sh -e 2# 3# rc.local 4# 5# This script is executed at the end of each multiuser runlevel. 6# Make sure that the script will "exit 0" on success or any other 7# value on error. 8# 9# In order to enable or disable this script just change the execution 10# bits. 11# 12# By default this script does nothing. 13 14chmod 755 /etc/rc.local 15sudo /home/sni/NTP/a.out & 16 17exit 0
と追記して再起動をしてみたところ、何も動きがありませんでした。
また、ps -xでプロセスを確認してみましたがそこにもありませんでした。
.config/autostart/gnome-terminal.desktop で行った際は
[Desktop Entry] Exec=gnome-terminal -e "/home/name/Test/a.out" Type=Application
と記述して再起動しましたが、やはり動きがありませんでした。
他の方法なども模索しているのですが、なかなかうまく見つけられません。
なぜうまくいかないのか、何か別の方法はないのか、ご教授お願い致します。
また、実行環境は
・VirtualBox 6.1
・ubuntu 14.04.6 LTS
・gcc 4.8.4
です。
回答1件
あなたの回答
tips
プレビュー