mbah_bejo

no1 sisop modul2

Apr 16th, 2021
562
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <sys/types.h>
  4. #include <unistd.h>
  5. #include <wait.h>
  6. #include <time.h>
  7. #include <string.h>
  8. #include <glob.h>
  9.  
  10. char path[20];
  11.  
  12. void filter(){
  13.   int status,status1,status2;
  14.   printf(" masuk");
  15.     if (0 == fork()) {
  16.     glob_t globbuf_film;
  17.     globbuf_film.gl_offs = 2;
  18.     glob("FILM/*.mp4", GLOB_DOOFFS, NULL, &globbuf_film);
  19.     glob("Fylm/", GLOB_DOOFFS | GLOB_APPEND, NULL, &globbuf_film);
  20.     globbuf_film.gl_pathv[0] = "cp";
  21.     globbuf_film.gl_pathv[1] = "-r";
  22.     execvp("cp", &globbuf_film.gl_pathv[0]);
  23.     }
  24.     while ((wait(&status)) > 0);
  25.  
  26.     if(0==fork()){
  27.     glob_t globbuf_foto;
  28.     globbuf_foto.gl_offs = 2;
  29.     glob("FOTO/*.jpg", GLOB_DOOFFS, NULL, &globbuf_foto);
  30.     glob("Pyoto/", GLOB_DOOFFS | GLOB_APPEND, NULL, &globbuf_foto);
  31.     globbuf_foto.gl_pathv[0] = "cp";
  32.     globbuf_foto.gl_pathv[1] = "-r";
  33.     execvp("cp", &globbuf_foto.gl_pathv[0]);
  34.     }
  35.     while ((wait(&status1)) > 0);
  36.  
  37.     if(0==fork()) {
  38.     glob_t globbuf;
  39.     globbuf.gl_offs = 2;
  40.     glob("MUSIK/*.mp3", GLOB_DOOFFS, NULL, &globbuf);
  41.     glob("Musyik/", GLOB_DOOFFS | GLOB_APPEND, NULL, &globbuf);
  42.     globbuf.gl_pathv[0] = "cp";
  43.     globbuf.gl_pathv[1] = "-r";
  44.     execvp("cp", &globbuf.gl_pathv[0]);
  45.     }
  46.     while ((wait(&status2)) > 0);
  47. }
  48.  
  49. void download(){  
  50.   pid_t child_id;
  51.   int i,status,status1,status2,status3;
  52.   child_id = fork();
  53.  
  54.   if (child_id < 0) {
  55.     exit(EXIT_FAILURE); // Jika gagal membuat proses baru, program akan berhenti
  56.   }
  57.  
  58.   if (child_id == 0) {
  59.     // this is child
  60.     char *argv[3][7] = {    
  61.     {"/usr/bin/wget", "wget", "--no-check-certificate", "https://drive.google.com/uc?id=1ZG8nRBRPquhYXq_sISdsVcXx5VdEgi-J&export=download", "-O", "Musik_for_Stevany.zip", 0},
  62.     {"/usr/bin/wget", "wget", "--no-check-certificate", "https://drive.google.com/uc?id=1FsrAzb9B5ixooGUs0dGiBr-rC7TS9wTD&export=download", "-O", "Foto_for_Stevany.zip", 0},
  63.     {"/usr/bin/wget", "wget", "--no-check-certificate", "https://drive.google.com/uc?id=1ktjGgDkL0nNpY-vT7rT7O6ZI47Ke9xcp&export=download", "-O", "Film_for_Stevany.zip", 0}};
  64.     for(i = 0; i< 3;i++ ){
  65.       if (0 == fork()){
  66.         while ((wait(&status1)) > 0);
  67.         continue;
  68.       }
  69.       while ((wait(&status2)) > 0);
  70.       execv("/usr/bin/wget", &argv[i][0]);    
  71.     }
  72.  
  73.     char *argv_3[] = {"unzip", "*.zip", NULL};
  74.     execv("/usr/bin/unzip", argv_3);        
  75.     }
  76.    else{
  77.     // this is parent
  78.     while ((wait(&status)) > 0);
  79.     char *argv_1[3][5] = {
  80.     {"/bin/mkdir", "-p", "Musyik", 0},
  81.     {"/bin/mkdir", "-p", "Fylm", 0},
  82.     {"/bin/mkdir", "-p", "Pyoto", 0}};
  83.     for(i = 0; i< 3;i++ ){
  84.       if (0 == fork()) continue;
  85.       execve(argv_1[i][0], &argv_1[i][0], NULL);
  86.      }
  87.     while ((wait(&status3)) > 0);
  88.     filter();
  89.     }
  90.    
  91. }
  92.  
  93. void hd(){
  94.   int status;
  95.   time_t t_now = time(NULL);
  96.   struct tm waktu = *localtime(&t_now);
  97.  
  98.   pid_t child_id;
  99.   child_id = fork();
  100.  
  101.   if (child_id < 0) {
  102.     exit(EXIT_FAILURE); // Jika gagal membuat proses baru, program akan berhenti
  103.   }
  104.  
  105.   if (child_id == 0) {
  106.     strftime(path, sizeof(path)-1, "%d-%m_%H:%M", &waktu);
  107.  
  108.     while(strcmp(path,"09-04_22:22") <=0)
  109.     {
  110.     sleep(2);
  111.     t_now = time(NULL);
  112.     waktu = *localtime(&t_now);
  113.     strftime(path, sizeof(path)-1, "%d-%m_%H:%M", &waktu);
  114.     if(strcmp(path,"09-04_22:22")==0){
  115.     char *argv_6[] = {"rm","-rf", "MUSIK", "FOTO", "FILM", NULL};
  116.     execv("/bin/rm", argv_6);
  117.     }
  118.     }
  119.   } else{
  120.     while(wait(&status)>0);
  121.     char *argv_4[] = {"zip", "-rm", "Lopyu_Stevany", ".", "-x", "soal1*", "*.zip", NULL};
  122.     execv("/bin/zip", argv_4);
  123.     exit(1);
  124.   }
  125.  
  126. }
  127. int main() {
  128.   // setvbuf(stdout, NULL, _IONBF, 0);
  129.   int status,status1;
  130.   time_t t_now = time(NULL);
  131.   struct tm waktu = *localtime(&t_now);
  132.   strftime(path, sizeof(path)-1, "%d-%m_%H:%M", &waktu);
  133.   while(strcmp(path,"09-04_16:22")!=0)
  134.   {
  135.     sleep(2);
  136.     t_now = time(NULL);
  137.     waktu = *localtime(&t_now);
  138.     strftime(path, sizeof(path)-1, "%d-%m_%H:%M", &waktu);
  139.   }
  140.   download();
  141.   while ((wait(&status)) > 0);  
  142.   hd();
  143.   while ((wait(&status1)) > 0);  
  144.   return 0;
  145. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×