Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #include <math.h>
  6. #include <sys/stat.h>
  7. #include <sys/types.h>
  8. #include <unistd.h>
  9. #include <zlib.h>
  10.  
  11. main(){
  12. const char *a[5];
  13. int i, j ,k, ii, jj, kk;
  14. char str[256];
  15. FILE *fp, *source, *target, *fp1;
  16. char ch[300];
  17. char str1[256];
  18. char sbuff[300];
  19.  
  20. printf("Start Here ...n");
  21.  
  22. a[0] = "submit.sh";
  23. a[1] = "run.prm";
  24. a[2] = "name.txt";
  25. a[3] = "prot.pdb";
  26. a[4] = "step2_out.pdb";
  27.  
  28. for (i=1;i<6;i++){
  29. sprintf(str,"_%d", i);
  30. mkdir(str, 0755); // Create temporary directories
  31.  
  32. for (j=0;j<5;j++){
  33. sprintf(str,"%s", a[j]);
  34. source = fopen(str, "r");
  35. if( source == NULL )
  36. {
  37. printf("Error in doStepOneAndTwo, can't open file source n");
  38. return -1;
  39. }
  40. sprintf(str,"_%d/%s", i, a[j]);
  41. target = fopen(str, "w+");
  42. if( target == NULL )
  43. {
  44. fclose(source);
  45. printf("Error in doStepOneAndTwo, can't open file target %s n",str);
  46. return -1;
  47. }
  48. while( (fgets(ch, sizeof(ch), source))) {
  49. if (j == 1){
  50. if (strstr(ch, "(DO_PREMCCE)")){
  51. ch[0] = 'f';
  52. }
  53. else if (strstr(ch, "(DO_ROTAMERS)")){
  54. ch[0] = 'f';
  55. }
  56. else if (strstr(ch, "(DO_MONTE)")){
  57. ch[0] = 'f';
  58. }
  59. else if (strstr(ch, "(DELPHI_STEP)")){
  60. ch[0] = 'f';
  61. }
  62. fputs(ch, target);
  63. }else {
  64. fputs(ch, target);
  65. }
  66.  
  67. }
  68. }
  69. sprintf(str1,"chmod +x _%d/submit.sh", i);
  70. system(str1);
  71.  
  72. // Submiting the jobs
  73. if (getcwd(sbuff, sizeof(sbuff)) != NULL)
  74. printf("Current working dir 1: %sn", sbuff);
  75. else
  76. printf("getcwd() error");
  77. sprintf(str,"_%d/", i);
  78. chdir(str);
  79. system("qsub submit.sh"); // This line doesn't works, the above directories are dynamically created (str)
  80. chdir(sbuff);
  81. }
  82.  
  83. // Submit the job
  84. chdir("1l2y");
  85. system("qsub submit.sh"); // This line works, the above directory is manually created (1l2y)
  86. chdir(sbuff);
  87.  
  88.  
  89.  
  90. return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement