一个月,学了很多东西,遇到很多问题,觉得自己很白菜,总归每天在进步,总结下
大概做了三件事:
- 设计实现商城道具管理系统,数据库(mysql)+后端(python,flask)+前端(js,html,css)
- 实现一个脚本解释器,c语言编程
- 实现一个运维脚本,shell编程
操作系统debian,连接远程服务器开发putty
- 商城道具管理系统
_mini.py (control层)
_view.py (view层)
_dao.py (model层)
_template (html)
_static (图片,js,css)
- 脚本解释器
类似bash
#define TRUE 1 #define max_name 256 #define max_path 1024 #define max_prompt 1024 #define MAXLINE 4096 #define MAXARG 20 #define MAXPIDTABLE 1024 #define BACKGROUND 1 #define IN_REDIRECT 2 #define OUT_REDIRECT 4 #define OUT_REDIRECT_APPEND 8 #define IS_PIPED 16 #define MAX_TYPE_PROMPT 20 #ifdef READLINE_ON #include <readline/readline.h> #include <readline/history.h> #endif #include <unistd.h> #include <pwd.h> #include <signal.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <errno.h> #include <fcntl.h> #include <sys/types.h> #include <sys/wait.h> struct parse_info { int flag; char* in_file; char* out_file; char* command2; char** parameters2; }; char *buffer; pid_t BPTable[MAXPIDTABLE]; struct passwd *pwd; //显示个性化的命令行提示符 void display(char *prompt){ pwd=getpwuid(getuid());//get recent uid char hostname[max_name]; char pathname[max_path]; int len; getcwd(pathname,max_path);//get recent pathname if(gethostname(hostname,max_name)==0)//get hostname sprintf(prompt,"[qjjshell]%s@%s:",pwd->pw_name,hostname); else sprintf(prompt,"[qjjshell]%s@unknown:",pwd->pw_name); len = strlen(prompt); if(strlen(pathname) < strlen(pwd->pw_dir) || strncmp(pathname,pwd->pw_dir,strlen(pwd->pw_dir))!=0)//get pathname sprintf(prompt+len,"%s",pathname); else sprintf(prompt+len,"~%s",pathname+strlen(pwd->pw_dir)); len = strlen(prompt); if(geteuid()==0)//get premission sprintf(prompt+len,"#"); else sprintf(prompt+len,"$"); return; } //读取命令行输入的命令 int readcmd(char **command,char **parameters,char *prompt){ #ifdef READLINE_ON free(buffer); buffer = readline(prompt); if(feof(stdin)) { printf(" "); exit(0); } #else printf("%s",prompt); char* Res_fgets = fgets(buffer,MAXLINE,stdin); if(Res_fgets == NULL) { printf(" "); exit(0); } #endif if(buffer[0] == '