Changeset 2203 in Sophya for trunk/SophyaPI/PIext
- Timestamp:
- Oct 4, 2002, 3:25:17 PM (23 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/piacmd.cc
r1920 r2203 323 323 usage += " > listcommands # List of all known commands \n"; 324 324 usage += " > exec filename # Execute commands from file \n"; 325 usage += " > shell comand_string # Execute shell command \n";326 325 usage += " > help <command_name> # <command_name> usage info \n"; 327 326 usage += " > helpwindow # Displays help window \n"; 328 327 usage += " > timingon timingoff traceon traceoff \n"; 329 328 string grp = "Commands"; 329 RegisterHelp(kw, usage, grp); 330 331 kw = "shell execute"; 332 usage = "> shell command_string # Execute shell command\n"; 333 usage += "> cshell command_string # Execute cshell command\n"; 334 usage += "---Exemples:\n"; 335 usage += " > shell ls\n"; 336 usage += " > cshell echo '$LD_LIBRARY_PATH'; map2cl -h; ls\n"; 337 usage += " > shell myfile.csh [arg1] [arg2] [...]\n"; 338 usage += " (where the first line of \"myfile.csh\" is \"#!/bin/csh\")\n"; 330 339 RegisterHelp(kw, usage, grp); 331 340 … … 983 992 system(cmd.c_str()); 984 993 } 994 else if (kw == "cshell") { 995 if(tokens.size()<1) {cout<<"PIACmd::Interpret() Usage: cshell cmdline"<<endl; return(0);} 996 string cmd=""; 997 for(int ii=0;ii<tokens.size();ii++) cmd+=(tokens[ii]+' '); 998 CShellExecute(cmd); 999 } 985 1000 986 1001 // Execution d'une commande enregistree … … 1107 1122 } 1108 1123 1124 /* --Methode-- */ 1125 int PIACmd::CShellExecute(string cmd) 1126 { 1127 if(cmd.size()<=0) return -1; 1128 1129 NamedObjMgr omg; 1130 string fname = omg.GetTmpDir(); fname += "cshell_exec_pia.csh"; 1131 1132 string cmdrm = "rm -f " + fname; 1133 system(cmdrm.c_str()); 1134 1135 FILE *fip = fopen(fname.c_str(),"w"); 1136 if(fip==NULL) { 1137 cout << "PIACmd/CShellExecute_Error: fopen("<<fname<<") failed"<<endl; 1138 return -2; 1139 } 1140 fprintf(fip,"#!/bin/csh\n\n"); 1141 fprintf(fip,"%s\n",cmd.c_str()); 1142 fprintf(fip,"\nexit 0\n"); 1143 fclose(fip); 1144 1145 cmd = "csh "; cmd += fname; 1146 system(cmd.c_str()); 1147 1148 system(cmdrm.c_str()); 1149 1150 return 0; 1151 } 1109 1152 1110 1153 static string* videstr = NULL; -
trunk/SophyaPI/PIext/piacmd.h
r1920 r2203 82 82 virtual int ExecuteCommand(string& keyw, vector<string>& args, string& toks); 83 83 virtual int ExecFile(string& file, vector<string>& args); 84 84 virtual int CShellExecute(string cmd); 85 85 virtual string& GetUsage(const string& kw); 86 86
Note:
See TracChangeset
for help on using the changeset viewer.