我想通过C程序中的execl函数调用执行winexe命令。 如果我在execl调用中硬编码凭证和机器名称,它的工作原理如下
execl("winexe","winexe","-U","Domain/Username%Password","//hostname","ipconfig",NULL)
但是,如果我用变量替换主机名或凭证,它就无法正常工作。
execl("winexe","winexe","-U",credentials_variable,hostname_variable,"ipconfig",NULL)
输出:
winexe version 1.00
This program may be freely redistributed under the terms of the GNU GPLv3
Usage: winexe [-?] [-?] [-?] [-?NP] [-?NPV] [-?|--help] [--usage] [-d|--debuglevel DEBUGLEVEL]
[--debug-stderr] [-s|--configfile CONFIGFILE] [--option=name=value]
[-l|--log-basename LOGFILEBASE] [--leak-report] [--leak-report-full]
[-R|--name-resolve NAME-RESOLVE-ORDER]
[-O|--socket-options SOCKETOPTIONS] [-n|--netbiosname NETBIOSNAME]
[-S|--signing on|off|required] [-W|--workgroup WORKGROUP]
[--realm=REALM] [-i|--scope SCOPE] [-m|--maxprotocol MAXPROTOCOL]
[-U|--user [DOMAIN/]USERNAME[%PASSWORD]] [-N|--no-pass]
[--password=STRING] [-A|--authentication-file FILE] [-P|--machine-pass]
[--simple-bind-dn=STRING] [-k|--kerberos STRING] [-V|--version]
[--uninstall] [--reinstall] [--system]
[--runas=[DOMAIN\]USERNAME%PASSWORD] [--runas-file=FILE]
[--interactive=0|1] [--ostype=0|1|2] //host command
以上输出表明它是语法错误。但我在变量中使用了确切的字符串,包括/和%。请注意,我正在从文件中读取上述变量。我已经使用execl函数将变量作为参数传递给其他命令,但我不知道为什么winexe不工作!
请告诉我如何在execl函数调用中将变量用作winexe参数。