시스템프로그래밍 Lecture4,5 linux command, string
*지*
다운로드
장바구니
소개글
수정할 곳 없는 정말 완벽한 보고서입니다.보고서 쓰시는데 도움이 되었으면 좋겠습니다.
목차
Lecture4 : linux command9) Redirect the output of ex1 to another file using ">" symbol.
10) Use grep to search "hello" in all files (use –nr option).
11) Find out what processes exist in your system. Use "ps –ef".
12) "ps -ef" shows all the processes in the system. How do you know which ones are yours? Remember all of you are using the same user ID, and the question is how you can tell which processes belong to you. Use "tty" for this purpose.
13) Modify ex1.c so that it receives two numbers from the user and prints the sum. Use scanf() for this.
14) Modify ex1.c so that it contains an infinite loop after printing "hello".
15) Run the program with & at the end, and use ps to check its status.
16) Kill it.
17) Run the program again without & at the end. Open another login window, find out the process ID of the process running in the first window, and kill it.
18) Use objdump to dump the assembly code of ex1. The dump file is very long. How can you read this file?
19) Write a program to read a sentence and echo it as follows.
Lecture5 : string
hw5-1) Try above code.
hw5-2) Same as 1), but print all ascii codes for characters in x[0] to x[9].
hw5-3) Declare a character array with 128 rooms. Store 0 to 127 in this array and print the corresponding character for each ascii code in the array. Find ASCII table in the Internet and confirm the results.
hw5-3-1) Generate a random 5-letter name using rand() function. Read a 5-letter name from the user and check if they are same.
hw5-5) Define a character array x with 50 rooms. Store “hello” in x. Print x. Compare x with “hel” and “hello” using strcmp(). What are the comparison results? Display each character in x using %c and %d. What is the length of x?
hw5-6) Read a mixture of an integer, string, character and display them. Use scanf() to read the inputs.
hw 5-7-1) Do hw 5-3-1) again, but this time store the random name as a string in name1. name1 should have a length of at least 6. Use strcmp() to implement eqname().
char name1[6];
5-10) Use strtok to extract words from a sentence and store them in an array. Display the number of words as below.
본문내용
9) Redirect the output of ex1 to another file using ">" symbol.처음에는 ex라는 파일이 없었으나 >심볼을 사용하여 ex을 생성하고 ex1.c의 결과를 복사하고 실행하였다.
10) Use grep to search "hello" in all files (use –nr option).
$ grep는 해당 문자열이 포함된 파일을 찾아주는 명령어입니다. 여기에 –nr이라는 option을 사용하여 해당 문자열이 파일에서 몇 번째 라인인지 검색하여 나타내줍니다.
11) Find out what processes exist in your system. Use "ps –ef".
$ ps –e : 현재 실행중인 모든 프로세스를 표시한다.
$ ps -f : 프로세스 시작시간, 프로세스의 부모 ID, 그 프로세스에 관련된 사용자ID, 명령 이름과 가능한 매개변수(있다면) 등 모든 정보를 출력한다.
$ ps -p(pid) : 지정된 프로세스에 대한 정보를 출력한다.
$ ps -t(tty) : 지정된 터미널에 연관된 프로세스에 대한 정보를 출력한다.
$ ps -u(uid) : 지정된 사용자에 연관된 프로세스에 대한 정보를 출력한다.
<중 략>
$ kill : 프로세스에 시그널을 전송하는 명령어이다. 시그널 지정을 생략한 경우, TERM 시그널을 전송하여 프로세스를 전송시킨다. 쉘 빌트인으로서의 KILL명령어는 프로세스 ID 대신 job 번호를 사용할 수 있다.
$ kill [PID] : 시그널을 보내고 싶은 프로세서의 ID를 지정하여 종료한다.
Ctrl+c를 이용하여 프로그램을 강제 종료할 수 있고, Kill 명령어를 사용하여 종료할 수 있다.
17) Run the program again without & at the end. Open another login window, find out the process ID of the process running in the first window, and kill it.
tty 명령어를 이용하여 현재 나의 터미널명이 pts/1이라는 것을 알 수 있고, ./ex1 명령어로 실행시킨다.