I'm trying to automate a simple task.
This task requires that I login into an application. And this application requires I enter a password!
A simple attempt to login on command line would be like:
vv -u myuser login
Enter password:
And this waits for my input.
How can I pass my password to it?
I tried the following
echo "mypassword" | vv -u myuser login
echo "mypassword" | -S vv -u myuser login
Neither worked! It's actually returning "Invalid password" but if I type the password manually it works.
Try
echo(mypassword| vv -u myuser login
no spaces or quotes around the password
Related
I would like to create a .bat or .lnk file (preferably a .lnk file) to automate the following sequence in cmd for me:
>runas /user:5CG95082M0\School "C:\Users\School\AppData\Local\Microsoft\Teams\Update.exe --processStart "Teams.exe""
Enter the password for 5CG95082M0\School: [my user password is an input here]
Attempting to start C:\Users\School\AppData\Local\Microsoft\Teams\Update.exe --processStart Teams.exe as user "5CG95082M0\School" ...
here is my question: how do I make the file to automatically input my user password when it is prompted I should do so?
Notice that the command is runas and that it waits for a user input. I've read that the use of echo to do that has been removed. As a proof (or is it?), note this when ran on cmd:
C:\Users\7329934>echo [my password] | runas /user:5CG95082M0\School "C:\Users\School\AppData\Local\Microsoft\Teams\Update.exe --processStart "Teams.exe""
Enter the password for 5CG95082M0\School:
Attempting to start C:\Users\School\AppData\Local\Microsoft\Teams\Update.exe --processStart Teams.exe as user "5CG95082M0\School" ...
RUNAS ERROR: Unable to run - C:\Users\School\AppData\Local\Microsoft\Teams\Update.exe --processStart Teams.exe
1326: The user name or password is incorrect.
Any thoughts?
Thanks
I am trying to build the Cache database and calling the command
echo do ##class(SYS.Database).DismountDatabase("%CACHE_DIR%\CODE") Halt EOT | %CACHE_DIR%\bin\cache.exe -s %CACHE_DIR%\mgr -U %SYS
But after that immediately displays a message:
Username:
Password:
Access Denied
How to pass parameters(username, password) to cache.exe in bat file?
I haven't found --help or something like this.
Try something like:
%CACHE_DIR%\bin\csession CACHE20172 -U %SYS "##class(SYS.Database).DismountDatabase(""%CACHE_DIR%\CODE"")"
I've been trying to pass a variable value that i can enter in the command line to open a batch file and then pass that value to an sql script. In this instance I'm looking to change a database user's password to a new password by setting it in the command line.
command line - update_passwords.bat server_name 1234
batch file -
#echo off
set sql_server_name=%1
set newPass=%2
osql -S %1 -U dbuser -P user_pass -v newPass=%2 -i c:\sql_script -o c:\sql_log
sql file -
ALTER LOGIN user1 WITH PASSWORD = %2;
I get an incorrect syntax near '%' error when I run the the batch file
Any help is greatly appreciated
There are two main issues. One is that %2 won't be available in c:\sql_script, so the SQL statement is trying to set the password to "%2", literally. You could resolve that by passing the SQL statement on the command line instead of in an input file. The second issue is that the SQL statement needs quotes around the %2. Try the following.
osql -S %1 -U dbuser -P user_pass -q "ALTER LOGIN user1 WITH PASSWORD = '%2';" -o c:\sql_log
Now, if the new password has apostrophes in it, you would need to escape them by converting them to double apostropes.
Given that you're not using the sql_server_name and newPass variables after setting them, you can remove them completely. This will remove the security issue mentioned by shawnt00.
I'm having some problem with connecting to database with sqlplus in batchfile.
I'm trying to create a batch-script which prompt for server/service_name, username and password.
It looks something like this:
set /P ORCL=Enter server or service_name:
set /P UN=Enter DB User:
set /P PWD=Enter password for DB user:
sqlplus %UN%/%PWD%#ORCL #.\File_to_run.sql
...
I'm not using TNS locally, but connecting With machinename, like this:
username/password#machinename:1521/service_name
This Works just fine when I starting sqlplus through cmd prompt, but not when I'm running this bat-file. It says that the username or password is wrong and prompting for a username and password...
I think it might be something With the ORCL variable when put into the parameterlist of sqlplus. But I have tried quoting it like this:
...
sqlplus %UN%/%PWD%"#ORCL" #.\File_to_run.sql
and
sqlplus %UN%/%PWD%#"ORCL" #.\File_to_run.sql
But no success...
If I try the same, but instead of #service_name/_string using "AS sysdba" and corresponding username and password, it will work fine.
Does anybody know how to get this right?
BR
FAO
Please use percent sign for the last parameter too. Like:
sqlplus "%UN%/%PWD%#%ORCL%" #.\File_to_run.sql
I'm not sure why you need the # sign before .\File_to_run.sql...
I have a BAT file that runs a script on oracle :
sqlplus myuser/mypassword#mydatabase #C:\runthisfile.sql
I want to distribute this to other users (that don't necessarily know how to modify a BAT file).
I want the dos prompt to ask the user to enter their user and password (obviously I don't want to give them my connection details). Have tried all types of combination but all that happens is that I end up with SQL>......
Am stumped!
You can use the SET command with the /P argument in order to prompt the user for text during a batch file run, for example:
SET /P variable=Please enter text
This will then fill variable with whatever they type before hitting return.
#ECHO OFF
SET /P uname=Username:
SET /P pass=password:
This is a simple program which will prompt the first for a username, then a password.
You should then be able to pass this as an argument to sqlplus:
sqlplus %uname%/%pass%#mydatabase #C:\runthisfile.sql
Regarding with SQLPlus stop, doing nothing:
Sometimes SQLPlus finish with ... meaning that is waiting for something more.
Try to add "/" (without quotes) in the end of your SQL file to execute it.
I hope it will help...
It is the very simple code for opening SQLPLUS without entering usename and password manually.
sqlplus -L UserName/Password
For example : sqlplus -L Rak4ak#sun64/rk4
For Understanding :
sqlplus [ [] [{logon | /nolog}] [] ]
is: [-C ] [-L] [-M ""] [-NOLOGINTIME] [-R ]
[-S]
-C <version> Sets the compatibility of affected commands to the
version specified by <version>. The version has
the form "x.y[.z]". For example, -C 10.2.0
-L Attempts to log on just once, instead of
reprompting on error.
-M "<options>" Sets automatic HTML markup of output. The options
have the form:
HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text]
[ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
-NOLOGINTIME Don't display Last Successful Login Time.
-R <level> Sets restricted mode to disable SQL*Plus commands
that interact with the file system. The level can
be 1, 2 or 3. The most restrictive is -R 3 which
disables all user commands interacting with the
file system.
-S Sets silent mode which suppresses the display of
the SQL*Plus banner, prompts, and echoing of
commands.
is: {[/][#] | / }
[AS {SYSDBA | SYSOPER | SYSASM | SYSBACKUP | SYSDG | SYSKM}] [EDITION=value]
Specifies the database account username, password and connect
identifier for the database connection. Without a connect
identifier, SQL*Plus connects to the default database.
The AS SYSDBA, AS SYSOPER, AS SYSASM, AS SYSBACKUP, AS SYSDG,
and AS SYSKM options are database administration privileges.