sas curl登录到安全的动态网站
论坛新成员。我想知道是否有人知道Curl如何使用SAS处理动态页面。例如,我尝试使用下面类似的代码在Base SAS中卷曲下面的动态页面:结果显示“objId”无法识别为内部或外部命令、可操作程序或批处理文件。程序或批处理文件。有人有什么想法吗?提前谢谢sas curl登录到安全的动态网站,curl,sas,Curl,Sas,论坛新成员。我想知道是否有人知道Curl如何使用SAS处理动态页面。例如,我尝试使用下面类似的代码在Base SAS中卷曲下面的动态页面:结果显示“objId”无法识别为内部或外部命令、可操作程序或批处理文件。程序或批处理文件。有人有什么想法吗?提前谢谢 %let a = ll; %let b = 1117016710; data _null_; call symput ('curl_cmd', "&curl_executable -k -u &userpass %nrstr
%let a = ll;
%let b = 1117016710;
data _null_;
call symput ('curl_cmd', "&curl_executable -k -u &userpass %nrstr(https://mysite.com/kl/livelink.exe?func=)&a^%nrstr(&objId=)&b ");
run;
filename curl pipe "&curl_cmd" lrecl=32767;
data tmp;
length xml $&maxchars;
infile curl truncover end=eof;
input @1 xml $&maxchars..;
if lengthn(xml) ge &maxchars then do;
put "ERROR: FAILED FOR process BECAUSE XML WAS > &maxchars CHARS";
put "OBSERVATION: " _n_;
put xml;
stop;
end;
run;
filename curl clear;
the results shows:
filename curl pipe "&curl_cmd" lrecl=32767;
WARNING: Apparent symbolic reference OBJID not resolved.
PROCESS=C:\test\curl\curl.exe -k -u user:pwd
https://mysite.com/kl/livelink.exe?func=ll^&objId=1117016710,
RECFM=V,LRECL=32767
Stderr output:
Total Received Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0
0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
NOTE: 0 records were read from the infile CURL.
NOTE: The data set WORK.TMP has 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.35 seconds
根据Joe的建议,我做了一些更改,结果如下:
%let curl_executable = C:\test\curl\curl.exe;
%let maxchars = 3000;
%let userpass = user:pwd;
%let a = ll;
%let b = 1117016710;
%let curl_cmd=&curl_executable -k -u &userpass %nrstr(https://mysite.com/kl/livelink.exe?func=)&a.%nrstr(&objId)=&b ;
%put &=curl_cmd;
data _null_;
call symput ('curl_cmd', '&curl_executable -k -u &userpass %nrstr(https://mysite.com/kl/livelink.exe?func=)&a.%nrstr(&objId)=&b');
run;
%put &=curl_cmd;
filename curl pipe "&curl_cmd" lrecl=32767;
data tmp;
length xml $&maxchars;
infile curl truncover end=eof;
input @1 xml $&maxchars..;
if lengthn(xml) ge &maxchars then do;
put "ERROR: FAILED FOR process BECAUSE XML WAS > &maxchars CHARS";
put "OBSERVATION: " _n_;
put xml;
stop;
end;
run;
filename curl clear;
结果日志文件返回:
37 %let curl_executable = C:\test\curl\curl.exe;
38 %let maxchars = 3000;
39 %let userpass = user:pwd;
40 %let a = ll;
41 %let b = 1117016710;
42 %let curl_cmd=&curl_executable -k -u &userpass
42 ! %nrstr(https://mysite.com/kl/livelink.exe?func=)&a.%nrstr(&objId)=&b
42 ! ;
43 %put &=curl_cmd;
CURL_CMD=C:\test\curl\curl.exe -k -u user:pwd
https://mysite.com/kl/livelink.exe?func=ll&objId=1117016710
44
45 data _null_;
46 call symput ('curl_cmd', '&curl_executable -k -u &userpass
46 ! %nrstr(https://mysite.com/kl/livelink.exe?func=)&a.%nrstr(&objId)=&b'
46 ! );
47 run;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
48 %put &=curl_cmd;
CURL_CMD=C:\test\curl\curl.exe -k -u user:pwd
https://mysite.com/kl/livelink.exe?func=ll&objId=1117016710
49
50 filename curl pipe "&curl_cmd" lrecl=32767;
51 data tmp;
52 length xml $&maxchars;
53
54 infile curl truncover end=eof;
55 input @1 xml $&maxchars..;
56
57 if lengthn(xml) ge &maxchars then do;
58 put "ERROR: FAILED FOR process BECAUSE XML WAS > &maxchars CHARS";
59 put "OBSERVATION: " _n_;
60 put xml;
61 stop;
62 end;
63 run;
NOTE: The infile CURL is:
Unnamed Pipe Access Device,
PROCESS=C:\test\curl\curl.exe -k -u user:pwd
https://mysite.com/kl/livelink.exe?func=ll&objId=1117016710,
RECFM=V,LRECL=32767
Stderr output:
Total Received Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0
0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
'objId' is not recognized as an internal or external command,
operable program or batch file.
NOTE: 0 records were read from the infile CURL.
NOTE: The data set WORK.TMP has 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.43 seconds
cpu time 0.04 seconds
64 filename curl clear;
NOTE: Fileref CURL has been deassigned.
65
66
67 proc print data=tmp;
68 run;
NOTE: No observations in data set WORK.TMP.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
关于宏对象未识别的警告令人恼火,但这不是问题所在。这只是说URL中的&OBJID没有解析。没关系,你想要一个对象 我怀疑您的问题是URL中的
^
字符。我怀疑您需要一个
来描述宏变量
您真的希望url为mysite.com/kl/livelink.exe吗?func=ll^&objId=1117016710?(添加空格以帮助它脱颖而出)如果错误检查实际上无法解决问题,则这可能有助于简化错误检查:
使用%let定义宏变量,而不是调用SYMPUT,除非您有充分的理由执行后者。在这种情况下,因为您使用宏变量作为组件,所以可能没有很好的理由这样做
%let a = ll;
%let b = 1117016710;
%let curl_executable=c:\curl.exe;
%let userpass=password;
%let curl_cmd=&curl_executable -k -u &userpass %nrstr(https://mysite.com/kl/livelink.exe?func=)&a%nrstr(&objId=)&b ;
%put &=curl_cmd;
第二,为了避免使用call-symput时出现警告,可以将其放在单引号中。别担心,&s在实际使用时仍然会得到解决
data _null_;
call symput ('curl_cmd', '&curl_executable -k -u &userpass %nrstr(https://mysite.com/kl/livelink.exe?func=)&a%nrstr(&objId=)&b');
run;
%put &=curl_cmd;
(旁注:&=仅适用于9.3+,因此如果您有9.2,请删除=)嗨,多姆帕兹,感谢您的快速反馈。我尝试了链接,但之前没有^nrstr(“);但它仍然为我提供了0条记录和有关objId的相同警告。它仅在动态页面中的行为类似。^将结束宏变量,因此这不是问题(除非^1是意外事件)。也就是说,最初的问题表明它不合适,所以我不明白它为什么会在那里。首先需要做的是按进程测试字符串输出。复制/粘贴从后面=到逗号之前的所有内容。在命令行执行它。如果行得通,那么您在将其正确发送到命令处理器时会遇到一些问题;如果是这样的话不起作用,请修复它使其起作用,然后更改您的SAS,使宏变量与之匹配。我编辑了我的帖子供您阅读日志文件。提前感谢您的建议。