亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: [求助]awk調(diào)用system返回127 [打印本頁]

作者: wiki09    時(shí)間: 2011-05-10 18:19
標(biāo)題: [求助]awk調(diào)用system返回127
本帖最后由 wiki09 于 2011-05-10 18:28 編輯

我需要用system調(diào)用創(chuàng)建目錄

以下是我的程序,它會(huì)在處理到第1184行時(shí)system調(diào)用就會(huì)返回127,之前都是正常。誰知道原因嗎??

代碼:
function dealfile
{
awk -F"|" '{ if( NR>1 ) { if( length($4)==13 ) {path="'$out_home'/"substr($4,2,3)"/"substr($4,5,3)"/"substr($2,2,; file=path"/"substr($4,8,3)".ph"    ; cmd="mkdir -p "path; cmdt="test -d "path; code=system(cmdt); if(code!=0) {    print cmdt;print code; code=system(cmd); print cmd;}} else { path="'$out_home'/other/"substr($4,2,length($4)-4)"/"substr($2,2,; file=path"/Content.ph"    ; cmd="mkdir -p "path; system(cmd);} print $0 >> file } }' $*
}

運(yùn)行后的錯(cuò)誤提示:
test -d /home/postgres/gcctest/cdr/shell/out/137/892/20101215
127
mkdir -p /home/postgres/gcctest/cdr/shell/out/137/892/20101215
127
test -d /home/postgres/gcctest/cdr/shell/out/150/102/20101215
127
mkdir -p /home/postgres/gcctest/cdr/shell/out/150/102/20101215
127
test -d /home/postgres/gcctest/cdr/shell/out/138/738/20101215
127
mkdir -p /home/postgres/gcctest/cdr/shell/out/138/738/20101215
127
test -d /home/postgres/gcctest/cdr/shell/out/138/731/20101215
127
mkdir -p /home/postgres/gcctest/cdr/shell/out/138/731/20101215
127
awk: (FILENAME=CF2710.all FNR=1185) fatal: can't redirect to `/home/postgres/gcctest/cdr/shell/out/138/731/20101215/156.ph' (沒有那個(gè)文件或目錄)
作者: zooyo    時(shí)間: 2011-05-10 21:33
提示: 作者被禁止或刪除 內(nèi)容自動(dòng)屏蔽
作者: wiki09    時(shí)間: 2011-05-11 08:28
主要功能就是將文件的內(nèi)容進(jìn)行分揀,按照文件里每行的某兩個(gè)字段的內(nèi)容將記錄按要求分成多個(gè)文件保存。

因?yàn)樾挛募谋4媛窂绞切枰鶕?jù)字段內(nèi)容生成的,所以,我是每處理一條記錄時(shí)就會(huì)system(test ...)這個(gè)路徑是否存在,如果不存在就system(mkdir -p ...),但是到了處理第1184調(diào)記錄(相當(dāng)于調(diào)用了1183次system("test ..."))時(shí),system調(diào)用就會(huì)返回127了(之后的一直都是返回127),之前是返回正常,要么是0要么是1。 求助。。。。有誰遇到過類似的情況???
作者: cjaizss    時(shí)間: 2011-05-11 08:51
trace跟蹤一下系統(tǒng)調(diào)用呢?
作者: wiki09    時(shí)間: 2011-05-11 09:27
謝謝版主,
我是新手,請(qǐng)問怎么跟在awk里的系統(tǒng)調(diào)用

我用strace -e trace=mkdir...跟蹤不出啥東東。。。
作者: wiki09    時(shí)間: 2011-05-11 09:51
22666 write(1, "test -d /home/postgres/gcctest/c"..., 62) = 62
22667 write(1, "127\n", 4)                    = 4

22668 rt_sigaction(SIGINT, {0x1, [], SA_RESTORER, 0x3f30430280}, {SIG_DFL, [], SA      _RESTORER, 0x3f30430280}, = 0
22669 rt_sigaction(SIGQUIT, {0x1, [], SA_RESTORER, 0x3f30430280}, {SIG_DFL, [], S      A_RESTORER, 0x3f30430280}, = 0
22670 rt_sigprocmask(SIG_BLOCK, [CHLD], [], = 0
22671 clone(child_stack=0, flags=CLONE_PARENT_SETTID|SIGCHLD, parent_tidptr=0x7ff      fded5e4a = 3696
22672 wait4(3696, [{WIFEXITED(s) && WEXITSTATUS(s) == 127}], 0, NULL) = 3696

22673 rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x3f30430280}, NULL, = 0
22674 rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER, 0x3f30430280}, NULL, =       0
22675 rt_sigprocmask(SIG_SETMASK, [], NULL, = 0
22676 --- SIGCHLD (Child exited) @ 0 (0) ---
22677 write(1, "mkdir -p /home/postgres/gcctest/"..., 63) = 63
22678 write(1, "127\n", 4)                    = 4

22679 open("/home/postgres/gcctest/cdr/shell/out/137/892/20101215/511.ph", O_WRON      LY|O_CREAT|O_APPEND, 0666) = -1 EMFILE (Too many open files)
22680 close(4)                                = 0
22681 munmap(0x2ac8cf348000, 4096)            = 0
22682 open("/home/postgres/gcctest/cdr/shell/out/137/892/20101215/511.ph", O_WRON      LY|O_CREAT|O_APPEND, 0666) = 4
22683 fstat(4, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
22684 fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
22685 fcntl(4, F_GETFL)                       = 0x8401 (flags O_WRONLY|O_APPEND|O      _LARGEFILE)
22686 fcntl(4, F_GETFL)                       = 0x8401 (flags O_WRONLY|O_APPEND|O      _LARGEFILE)
22687 fstat(4, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
22688 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =       0x2ac8cf348000
22689 lseek(4, 0, SEEK_CUR)                   = 0

22690 ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffded5eb00) = -1 ENOTTY (Inappr      opriate ioctl for device)
作者: wiki09    時(shí)間: 2011-05-11 10:01
和“Too many open files”這個(gè)有關(guān)嗎?怎么樣才能在腳本里關(guān)閉掉打開的文件呢?
作者: wiki09    時(shí)間: 2011-05-11 11:10
我用了ulimit -n 4096后,運(yùn)行正常了。

看來是打開文件過多這個(gè)錯(cuò)誤,影響了系統(tǒng)調(diào)用,導(dǎo)致system(test...)和system(mkdir -p ...)報(bào)錯(cuò)。

謝謝版主提示.




歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2