<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic way to sas to pass parameter to dos batch file is not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51935#M10927</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using PSFTP for executing dos batch file in sas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to pass parameter to batch file in sas and in batch file i have interpreted that passed parameter as %1 like below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sysexec psftp.exe &lt;A href="mailto:username@hostname"&gt;username@hostname&lt;/A&gt; -p&amp;nbsp; portnumber(22) -pw password -batch -b abc.bat d:\raj&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in abc.bat &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lcd %1&lt;/P&gt;&lt;P&gt;cd /home/comnest/&lt;/P&gt;&lt;P&gt;mget mkt*.csv&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but that %1 is not working as i am not getting any file transfer from /home/comnest to local directory d:\raj.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if i remove d:raj as below &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sysexec psftp.exe &lt;A href="mailto:username@hostname"&gt;username@hostname&lt;/A&gt; -p&amp;nbsp; portnumber(22) -pw password -batch -b abc.bat&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and in abc.bat&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lcd d:\raj&lt;/P&gt;&lt;P&gt;cd /home/comnest&lt;/P&gt;&lt;P&gt;mget mkt*.csv &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is working and getting files from /home/comnest to local directory d:\raj&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;..but i want to pass parameter to abc.bat d:\raj &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and can it replace %1 in abc.bat with value d:\raj&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have tried many times but it did not work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can you please help me on this .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Aug 2011 06:25:24 GMT</pubDate>
    <dc:creator>Rajendra</dc:creator>
    <dc:date>2011-08-22T06:25:24Z</dc:date>
    <item>
      <title>way to sas to pass parameter to dos batch file is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51935#M10927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using PSFTP for executing dos batch file in sas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to pass parameter to batch file in sas and in batch file i have interpreted that passed parameter as %1 like below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sysexec psftp.exe &lt;A href="mailto:username@hostname"&gt;username@hostname&lt;/A&gt; -p&amp;nbsp; portnumber(22) -pw password -batch -b abc.bat d:\raj&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in abc.bat &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lcd %1&lt;/P&gt;&lt;P&gt;cd /home/comnest/&lt;/P&gt;&lt;P&gt;mget mkt*.csv&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but that %1 is not working as i am not getting any file transfer from /home/comnest to local directory d:\raj.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if i remove d:raj as below &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sysexec psftp.exe &lt;A href="mailto:username@hostname"&gt;username@hostname&lt;/A&gt; -p&amp;nbsp; portnumber(22) -pw password -batch -b abc.bat&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and in abc.bat&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lcd d:\raj&lt;/P&gt;&lt;P&gt;cd /home/comnest&lt;/P&gt;&lt;P&gt;mget mkt*.csv &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is working and getting files from /home/comnest to local directory d:\raj&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;..but i want to pass parameter to abc.bat d:\raj &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and can it replace %1 in abc.bat with value d:\raj&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have tried many times but it did not work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can you please help me on this .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2011 06:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51935#M10927</guid>
      <dc:creator>Rajendra</dc:creator>
      <dc:date>2011-08-22T06:25:24Z</dc:date>
    </item>
    <item>
      <title>way to sas to pass parameter to dos batch file is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51936#M10928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;have you tried passing the -b parameter as a quoted string containing the .bat file and it's parameter?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2011 14:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51936#M10928</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-08-22T14:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: way to sas to pass parameter to dos batch file is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51937#M10929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Discussion moved to the SAS Macro Facility, Data Step and SAS Language Elements so that more people might find it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2011 14:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51937#M10929</guid>
      <dc:creator>reneeharper</dc:creator>
      <dc:date>2011-08-22T14:44:49Z</dc:date>
    </item>
    <item>
      <title>way to sas to pass parameter to dos batch file is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51938#M10930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Peter&lt;/P&gt;&lt;P&gt;i have created batch file extract_market_files.bat&amp;nbsp; which is ftping file from remote ftp server localtion /home/comnest/ to local machine directory d:\landing\&lt;/P&gt;&lt;P&gt;extract_market_files.bat is as below&lt;/P&gt;&lt;P&gt;lcd d:\landing\&lt;BR /&gt;cd /home/comnest/&lt;BR /&gt;mget mkt*.csv&lt;BR /&gt;quit&lt;/P&gt;&lt;P&gt;i am trying below command in sas for executing dos batch file which is running correctly.&lt;/P&gt;&lt;P&gt;%sysexec "D:\psftp &lt;A href="mailto:username@hostname"&gt;username@hostname&lt;/A&gt; -P 22 -pw password -batch -v -b&amp;nbsp; D:\extract_market_files.bat" &lt;/P&gt;&lt;P&gt;remote file are getting ftped to local directory d:\landing\.&lt;/P&gt;&lt;P&gt;but i wanted to pass local directory 'd:\landing\' as a parameter while executing extract_market_files.bat in sas&amp;nbsp; and read that parameter in dos batch file using&lt;/P&gt;&lt;P&gt; %1.&lt;/P&gt;&lt;P&gt;something like below&lt;/P&gt;&lt;P&gt;%sysexec "D:\psftp &lt;A href="mailto:username@hostname"&gt;username@hostname&lt;/A&gt; -P 22 -pw password -batch -v -b&amp;nbsp; D:\extract_market_files.bat d:\landing\" &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in batch file %1 should understand value d:\landing.&lt;/P&gt;&lt;P&gt;extract_market_files.bat&lt;/P&gt;&lt;P&gt;lcd %1&lt;BR /&gt;cd /home/comnest/&lt;BR /&gt;mget mkt*.csv&lt;BR /&gt;quit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is not ftping file from remote ftp location /home/comnest/ to local directory d:\landing\.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can you please suggest how to pass parameter from sas to dos batch file using psftp.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Aug 2011 04:40:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51938#M10930</guid>
      <dc:creator>Rajendra</dc:creator>
      <dc:date>2011-08-23T04:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: way to sas to pass parameter to dos batch file is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51939#M10931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did a test using SAS9.2 on Wndows 7:&lt;/P&gt;&lt;P&gt;Contents of&lt;STRONG&gt; test.bat&lt;/STRONG&gt; file&lt;STRONG&gt;:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;echo Parameter was&amp;nbsp; %1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SAS Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;%sysexec "c:\temp\test.bat Testing &amp;gt; c:\temp\result.txt ";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;result.txt&lt;/STRONG&gt; file contents after run:&lt;/P&gt;&lt;P&gt; C:\Users\SASJedi&amp;gt;echo Parameter was&amp;nbsp; Testing; &lt;/P&gt;&lt;P&gt;Parameter was&amp;nbsp; Testing;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Conclusion:&lt;/P&gt;&lt;P&gt;Parameter is passing OK to a normal DOS batch file&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Upon reviewing the documentation for PSFTP, I found instructions for writing scripts, but none for accepting parameters.&amp;nbsp; Perhaps this is problems stems from the PSFTP program itself. Consider re-writing your job as a DOS batch file (which will accept parameters) and let the DOS batch file execute PSFTP, or use a DATA _NULL_ step to write a customized copy of the extract_market_files.bat file which contains the hard-coded local directory name so it doesn't have to be passed as a parameter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Aug 2011 01:47:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51939#M10931</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2011-08-24T01:47:04Z</dc:date>
    </item>
    <item>
      <title>way to sas to pass parameter to dos batch file is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51940#M10932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my requirement is to pass parameter to dos batch file from sas using psftp protocol as file are residing on sftp server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any information for passing parameter to dos batch file from sas using psftp will be helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Aug 2011 11:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51940#M10932</guid>
      <dc:creator>Rajendra</dc:creator>
      <dc:date>2011-08-24T11:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: way to sas to pass parameter to dos batch file is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51941#M10933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It does not look like the psftp program does what you want it to do.&amp;nbsp; You can test that by taking SAS out of the problem and issuing the proposed command from a DOS prompt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it would be much easier to use SAS to write the script for psftp than to depend on an external file.&amp;nbsp; But you could use an external file as a model for the script that SAS would write.&amp;nbsp; The datastep below will replace all references to '%1' with the actual directory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let sdir=d:\raj ;&lt;/P&gt;&lt;P&gt;filename script temp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile 'abc.bat' ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; file script;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp; _infile_ = tranwrd(_infile_,'%1',"&amp;amp;sdir");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put _infile_;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sysexec psftp.exe &lt;A _jive_internal="true" href="https://communities.sas.com/mailto:username@hostname" style="font-size: 13px; color: #0e66ba;"&gt;username@hostname&lt;/A&gt; -p&amp;nbsp; portnumber(22) -pw password -batch -b %sysfunc(pathname(script)) ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Aug 2011 13:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/way-to-sas-to-pass-parameter-to-dos-batch-file-is-not-working/m-p/51941#M10933</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-08-24T13:13:46Z</dc:date>
    </item>
  </channel>
</rss>

