開発環境
- OS: macOS High Sierra - Apple
- IDE(統合開発環境): Xcode - Apple
- プログラミング言語: C
Head First C ―頭とからだで覚えるCの基本 (David Griffiths (著)、Dawn Griffiths (著)、中田 秀基 (監修)、木下 哲也 (翻訳)、オライリージャパン)の9章(プロセスとシステムサービス)、コードマグネット(p. 422)を取り組んでみる。
コードマグネット(p. 422)
// // main.c // sample1 // // Created by kamimura on 2018/02/21. // Copyright © 2018 kamimura. All rights reserved. // #include <stdio.h> #include <unistd.h> #include <string.h> #include <errno.h> int main(int argc, const char * argv[]) { char *feeds[] = { "http://sitekamimura.blogspot.com/feeds/posts/default", "http://sitekamimura.blogspot.com/feeds/comments/default", }; int times = 2; char *phrase = (char*)argv[1]; for (int i = 0; i < times; i++) { puts(feeds[i]); char var[255]; sprintf(var, "RSS_FEED=%s", feeds[i]); char *vars[] = {var, NULL}; pid_t pid = fork(); if (pid == -1) { fprintf(stderr, "プロセスをフォークできません: %s\n", strerror(errno)); return 1; } if (!pid) { if (execle("/usr/bin/python", "/usr/bin/python", "rssgossip.py", phrase, NULL, vars) == -1) { fprintf(stderr, "スクリプトを実行できません: %s\n", strerror(errno)); return 1; } } } return 0; }
入出力結果(Terminal)
$ ./rssgossip the >| output.txt $ cat output.txt http://sitekamimura.blogspot.com/feeds/posts/default http://sitekamimura.blogspot.com/feeds/comments/default Police raid police ball shooting. Out of the offic... Gclub The benefits of eating macadamia We choose... Gclub beware! Parking in front of the hous... The Golden Slots website will help you to win over... It was subsequently alarming during the time a new... Even though the wristwatches had been extensively ... With a very historical past guiding the idea, ther... What annoys my family some of the most with these ... - Survivors of the Holocaust talk about how they defied the odds to rebuild their lives in Australia - ! - Did the market crash today and what does it mean for you? - ! - There's another humanitarian crisis in Syria that could dwarf Aleppo - ! - Barnaby Joyce says end of his marriage 'one of the greatest failures of my life' - ! $ ./rssgossip JavaScript >| output.txt $ cat output.txt http://sitekamimura.blogspot.com/feeds/posts/default http://sitekamimura.blogspot.com/feeds/comments/default - Python - JavaScript - - 1 1 - () - Python - JavaScript - - 1 1 - () - Python - JavaScript - - - - () - Python - JavaScript - - 1 1 - () - Python - JavaScript - - - - (()) $
0 コメント:
コメントを投稿