I have a rather peculiar issue here.
Basically my objective is to replace a particular string with another string in a file.
Allow me elaborate.
I have within a file the statement
Code: Select all
sqlplus -s username/password @sqlfile.sql >>outputfile.sql
I have this vbscript that accepts the username/password string from user and stores it in an enviornment variable.
Next I have to replace the existing username/password with the username/password given by user.
For replacing I have another vbscript that takes the existing string , replacement string and filename as parameters and replaces the existing string with the replacement string.
The exact steps that I m following is
Code: Select all
rem userin.vbs takes the user input
start /w wscript.exe vb/userin.vbs
rem userin.bat set the user input as enviornment variable
call vb/userin.bat
del vb\userin.bat
rem finds the current sqlplus statement in the file and stores the entire string in myvar variable. (it will the statement as follows: sqlplus -S <current username/password> @temp1.sql >>opfile.sql)
for /f "tokens=*" %%a in (
'findstr sqlplus process\subshellexec.bat'
) do (
set myvar=%%a
)
rem set the user entered username/password string and store the entire sqlplus statement in newvar variable.
set newvar ='sqlplus -S %USERIN% @temp1.sql >>opfile.sql'
rem call replacedir.vbs which replaces the existing sqlplus sentence with the new sqlplus sentence.
call cscript vb/replacedir.vbs process\subshellexec.bat "%myvar%" "%newvar%"
Now the problem here is that the variable
Code: Select all
set newvar =set newvar ='sqlplus -S %USERIN% @temp1.sql >>opfile.sql'
is not getting initialized properly.
Infact, the string "sqlplus -S <new username/password> @temp1.sql" gets appended to opfile.sql file, because of ">>". And the variable newvar stores nothing.
How do I properly initialize the newvar variable without the information getting redirected?
Thanks.