当我尝试从C代码调用Shell脚本时输出不是预期的 [英] Output Is Not As Expected When I Try Calling Shell Script From C Code
本文介绍了当我尝试从C代码调用Shell脚本时输出不是预期的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个shell脚本,它从另一台服务器获取文件
I have a shell script it gets the files from another server
int main()
{
char y[18];
// copying the value into y
strcpy(y,"123456789.111");
// calling the shell script
system("/home/sandy/sftp2.sh y");
return 0;
} //end of main
这里我需要获取所有启动123456789.111的文件。我是新手,请帮助解决这个问题。
Here i need to get all the files that starts 123456789.111 . I am new to this please help to resolve this.
推荐答案
Quote:
system(/ home / sandy / sftp2.sh y);
system("/home/sandy/sftp2.sh y");
上面的行将字母' y
'作为脚本的参数传递给你可能想要的传递 y
变量值,即123456789.111
字符串。
但是,我想知道你为什么不直接写作
The above line passes the letter 'y
' as argument to the script while you probably want to pass the y
variable value, namely the "123456789.111"
string.
However, I wonder why don't you write directly
system("/home/sandy/sftp2.sh 123456789.111");
?
?
这篇关于当我尝试从C代码调用Shell脚本时输出不是预期的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文