Hi i have written a batch file to run a production job, batch file likes this
@echo off set /P uid="Enter username then press Enter: " set "psCommand=powershell -Command "$pword = read-host 'Enter password then press Enter' -AsSecureString ; ^ $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^ [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"" for /f "usebackq delims=" %%p in (`%psCommand%`) do set pwd=%%p "C:\Program Files\IBM\SPSS\Statistics\21\stats.exe" "J:\temp\GetData.spj" -production -server inet:stats01:3021 -user %uid% -password %pwd% now my problem is the Get data syntax in the GetData.spj contains the same user name and password as the ones i used to login to my server stats01. at the moment i have to hard code this into the syntax before i run my GetData.spj. I was wondering is there a way i can pass this %uid% and %pwd% into the syntax itself rather i change it manually? (reason is that it might be a different person runs the programme so they need to change the username and password in the syntax before running the batch file, i just wonder if it can be achieved in my way that only need to input the name and psword when running the batch file) Many thanks for the help. Thanks |
Yes. Take a look at the Production Facility (on Utilities) Runtime values using symbols starting with @ On Wed, Apr 6, 2016 at 5:04 AM, spssstarter <[hidden email]> wrote: Hi i have written a batch file to run a production job, batch file likes this |
Hi Jon,
thanks for your reply, i had a go on trying using the Runtime values, by replacing the text for username and password to %uid% and %pwd% respectively. And also modified my batch file text to @echo off set /P uid="Enter username then press Enter: " set "psCommand=powershell -Command "$pword = read-host 'Enter password then press Enter' -AsSecureString ; ^ $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^ [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"" for /f "usebackq delims=" %%p in (`%psCommand%`) do set pwd=%%p "C:\Program Files\IBM\SPSS\Statistics\21\stats.exe" "J:\temp\GetData.spj" -production -server inet:stats01:3021 silent -symbol @%uid% @%pwd% -user %uid% -password %pwd% It didnt work and no output produced. anything wrong? will you be able to give me any advise on this? Many thanks, Jenny |
See the topic in the Help It includes this example.
On Wed, Apr 6, 2016 at 8:58 AM, spssstarter <[hidden email]> wrote: Hi Jon, |
In reply to this post by spssstarter
It's stats.com that you need, also you made an error with the symbols: "C:\Program Files\IBM\SPSS\Statistics\21\stats.com" "J:\temp\GetData.spj"
=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
-production -server inet:stats01:3021 silent -symbol @uid %uid% @pwd %pwd% -user %uid% -password %pwd% Inside the syntax, you refer to @uid etc. These are actually macros generated by spss. 'ECHO "my uid: " + @uid.' should display the uid, provided that the quoting is correct. I would use SET PRINTBACK = NONE so the password is not echoed. Or use a DSN. Are you sure drive letters will work? Are they the same on the server? > Date: Wed, 6 Apr 2016 07:58:16 -0700 > From: daliufeng@GMAIL.COM > Subject: Re: [SPSSX-L] can you pass parameter into spss syntax in batch file? > To: SPSSX-L@LISTSERV.UGA.EDU > > Hi Jon, > thanks for your reply, i had a go on trying using the Runtime values, by > replacing the text for username and password to %uid% and %pwd% > respectively. And also modified my batch file text to > > @echo off > set /P uid="Enter username then press Enter: " > set "psCommand=powershell -Command "$pword = read-host 'Enter password then > press Enter' -AsSecureString ; ^ > > $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); > ^ > [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"" > for /f "usebackq delims=" %%p in (`%psCommand%`) do set pwd=%%p > > > "C:\Program Files\IBM\SPSS\Statistics\21\stats.exe" "J:\temp\GetData.spj" > -production -server inet:stats01:3021 silent -symbol @%uid% @%pwd% -user > %uid% -password %pwd% > > It didnt work and no output produced. anything wrong? will you be able to > give me any advise on this? > Many thanks, > Jenny > > > > -- > View this message in context: http://spssx-discussion.1045642.n5.nabble.com/can-you-pass-parameter-into-spss-syntax-in-batch-file-tp5731873p5731879.html > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD |
Hi albert,
Thank you for your reply. let me quickly explain here in what i would like to do, and if this is possible. My get data syntax looks this: GET DATA /TYPE=ODBC /CONNECT='DSN=APEX;UID=myusername;PWD=$o#v!@-O)J-A9x,-;SRVR=APEX.nss' /SQL='SELECT CREATED_BY, CREATED_DATE, HB_UNIFIED_HB, HB_SG_HB_2006, HB_NAME, HB_SG_HB_2014 '+ 'FROM CBDCS.HB_DATA' /ASSUMEDSTRWIDTH=255. CACHE. EXECUTE. SAVE OUTFILE='J:/temp/cb dataset.sav'. so this is the get data syntax to extract data from the system, as you can see there are username and password. the password is encrypted here this is generated by the spss by adding new query new data source etc, but the password is acutually the same as the one i used to login into the server in my batch file i mentioned in the earlier posts. so my aim is to run the production job in a batch file, but this production needs to run in the stats server so in my batch file , i have asked to input username and password at the beginning and so that they pass to my login details for stats server -server inet:stats01:3021 -user %uid% -password %pwd% i wonder if i can pass these to my Get Data syntax as they are the same username and password so that the person who runs this batch file does not need to change it manually every time. Thanks all for your patients and i hope to get some advise. Jenny |
In reply to this post by Jon Peck
Hi jon,
I now put /UNENCRYPTED in my get data syntax GET DATA /TYPE=ODBC /CONNECT='DSN=APEX;UID=myusername;PWD=mypassord;SRVR=APEX.nss' /UNENCRYPTED /SQL='SELECT CREATED_BY, CREATED_DATE, HB_UNIFIED_HB, HB_SG_HB_2006, HB_NAME, HB_SG_HB_2014 '+ 'FROM CBDCS.HB_DATA' /ASSUMEDSTRWIDTH=255. CACHE. EXECUTE. SAVE OUTFILE='J:/temp/cb dataset.sav'. so in the @datafile example, the @datafile is defined as /data/July_data.sav, so the prodjob1.spj is to run July_data.sav? I dont quite understand this example and cant see how it relates to my question. any more detailed advise for me to understand this ? Many thanks |
In reply to this post by spssstarter
You can test the code below interactively. Once it works, you remove the two Define commands, set mprint=off, printback=none, and try it on the server. When you create your .spj, be sure to use the quoting option, or else the + operator eill fail.
=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
define @uid () 'myuid' !enddefine. define @pwd () 'secret' !enddefine. preserve. set mprint = on printback = listing. GET DATA /TYPE=ODBC /CONNECT='DSN=APEX;' + 'UID=' + @uid + ';' + 'PWD=' + @pwd + ';' + 'SRVR=APEX.nss' /UNENCRYPTED /SQL='SELECT CREATED_BY, CREATED_DATE, HB_UNIFIED_HB, HB_SG_HB_2006, HB_NAME, HB_SG_HB_2014 '+ 'FROM CBDCS.HB_DATA' /ASSUMEDSTRWIDTH=255. cache. save outfile = ... restore. You might want to add an ORDER BY in your sql. Better to do this on a database. Also, drive letter "j:\" on server vs. client may be differently defined. Better use unc paths. > Date: Thu, 7 Apr 2016 02:14:24 -0700 > From: daliufeng@GMAIL.COM > Subject: Re: [SPSSX-L] can you pass parameter into spss syntax in batch file? > To: SPSSX-L@LISTSERV.UGA.EDU > > Hi albert, > Thank you for your reply. let me quickly explain here in what i would like > to do, and if this is possible. > My get data syntax looks this: > > GET DATA > /TYPE=ODBC > /CONNECT='DSN=APEX;UID=myusername;PWD=$o#v!@-O)J-A9x,-;SRVR=APEX.nss' > /SQL='SELECT CREATED_BY, CREATED_DATE, HB_UNIFIED_HB, HB_SG_HB_2006, > HB_NAME, HB_SG_HB_2014 '+ > 'FROM CBDCS.HB_DATA' > /ASSUMEDSTRWIDTH=255. > > CACHE. > EXECUTE. > > SAVE OUTFILE='J:/temp/cb dataset.sav'. > > so this is the get data syntax to extract data from the system, as you can > see there are username and password. the password is encrypted here this is > generated by the spss by adding new query new data source etc, but the > password is acutually the same as the one i used to login into the server in > my batch file i mentioned in the earlier posts. > > so my aim is to run the production job in a batch file, but this production > needs to run in the stats server so in my batch file , i have asked to input > username and password at the beginning and so that they pass to my login > details for stats server > > -server inet:stats01:3021 -user %uid% -password %pwd% > > i wonder if i can pass these to my Get Data syntax as they are the same > username and password so that the person who runs this batch file does not > need to change it manually every time. > Thanks all for your patients and i hope to get some advise. > Jenny > > > > -- > View this message in context: http://spssx-discussion.1045642.n5.nabble.com/can-you-pass-parameter-into-spss-syntax-in-batch-file-tp5731873p5731883.html > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD |
hi Albert,
I did try to use define !myuid() 'myuid' !enddefine. and tested in the syntax and see if i can pass parameters, it looks like it is not possible to pass parameters into CONNECT ? I think i probably will leave it just now, but i very appreciate your time and help . Jenny |
Free forum by Nabble | Edit this page |