Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pro*C无法读取从korn shell脚本传递的参数_Shell_Unix_Ksh - Fatal编程技术网

Pro*C无法读取从korn shell脚本传递的参数

Pro*C无法读取从korn shell脚本传递的参数,shell,unix,ksh,Shell,Unix,Ksh,我有一个KornShell脚本,它将把4个参数传递给一个Pro*C文件 korn shell脚本的语法如下所示: ### $command_dir/proc_file_name / $deptid $txdate $pid ### I hardcode the values for testing $command_dir/proc_file_name / 701 20170109 201701094444001 Pro*C文件的语法: .... main(argc, argv) in

我有一个KornShell脚本,它将把4个参数传递给一个Pro*C文件

korn shell脚本的语法如下所示:

###  $command_dir/proc_file_name / $deptid $txdate $pid

###  I hardcode the values for testing
$command_dir/proc_file_name / 701 20170109 201701094444001
Pro*C文件的语法:

....

main(argc, argv)
int argc
char *argv[];

username.len=strlen(argv[1]);
strncpy((char*)username.arr, argv[1],username.len);
username.arr[username.len]='\0';

deptid.len=strlen(argv[1]);
strncpy((char*)deptid.arr, argv[1],deptid.len);
deptid.arr[deptid.len]='\0';

txdate.len=strlen(argv[1]);
strncpy((char*)txdate.arr, argv[1],txdate.len);
txdate.arr[txdate.len]='\0';

pid=atoi(argv[4]);

printf("\n%s\n", username);
printf("\n%d\n", deptid);
printf("\n%d\n", txdate);
printf("\n%d\n", pid);

....
我发现这些参数的值不是我输入的。 请帮忙。。。
非常感谢您对username、deptid和txdate使用了相同的数组索引
1
。纠正这一点,你会很好

访问
argv[1]
等而不检查
argc
不是一个好做法。当在没有参数的情况下调用时,代码将导致核心转储


另外,我认为您的代码没有正确的语法。您能粘贴编译的代码吗?

在询问有关此问题之前,请确保检查基本语法。