質問編集履歴

1

プログラムでテキストファイルを出力するように変更。rc.localに「chmod 755 /etc/rc.local」の追加。

2022/04/11 06:11

投稿

tokotaku
tokotaku

スコア63

test CHANGED
File without changes
test CHANGED
@@ -5,12 +5,19 @@
5
5
  の2つです。
6
6
 
7
7
  実行したいファイルは以下のように、
8
- ただ「Hello World」を表示するだけの簡単なコンソールアプリです。
8
+ ただ「Hello World」を表示のと、ファイル出力するだけの簡単なコンソールアプリです。
9
9
  ```C言語
10
10
  #include <stdio.h>
11
+ #include <stdlib.h>
11
12
  int main(void)
12
13
  {
13
14
  printf("Hello World!\n");
15
+
16
+ FILE *fp;
17
+ fp = fopen("test.text", "w");
18
+ fprintf(fp, "Hello World!\n");
19
+ fclose(fp);
20
+
14
21
  return 0;
15
22
  }
16
23
  ```
@@ -22,7 +29,25 @@
22
29
  のみとなっております。
23
30
 
24
31
  rc.localで行った際は
32
+ ```rc.local
33
+ #!/bin/sh -e
34
+ #
35
+ # rc.local
36
+ #
37
+ # This script is executed at the end of each multiuser runlevel.
38
+ # Make sure that the script will "exit 0" on success or any other
39
+ # value on error.
40
+ #
41
+ # In order to enable or disable this script just change the execution
42
+ # bits.
43
+ #
44
+ # By default this script does nothing.
45
+
46
+ chmod 755 /etc/rc.local
25
- /home/name/Test/a.out
47
+ sudo /home/sni/NTP/a.out &
48
+
49
+ exit 0
50
+ ```
26
51
  と追記して再起動をしてみたところ、何も動きがありませんでした。
27
52
  また、ps -xでプロセスを確認してみましたがそこにもありませんでした。
28
53