I've been looking for a way to update my CCRC view via windows command line in a non-interactive way.
I'm using Jenkins and today there isn't a plugin for CCRC yet (https://issues.jenkins-ci.org/browse/JENKINS-5192), so I'm trying, as a first step, to auto update my CCRC view via batch script. I installed Managed Script Plugin (https://wiki.jenkins-ci.org/display/JENKINS/Managed+Script+Plugin) and wrote this simple script:
cd C:\Views\PathToMyViewVOB
rcleartool login -lname MyUser -server MyServer.com -password MyPass
rcleartool update
With this script, in the first execution, the login works correctly, but, I don't know why, Jenkins ignores the update command. In the following executions, it shows this error:
CRCLI2014E You have already logged on the server
"MyServer.com".
Build step 'Execute managed windows batch' marked build as failure
Finished: FAILURE
I've also tried with this other command, thinking that you can pass my credentials with any subcommands of rcleartool:
cd C:\Views\PathToMyViewVOB
rcleartool update -username MyUser -password MyPass -server MyServer.com
And this is the error now:
CRCLI2001E Unrecognized option: "-username".
Use: update [-print] [-ove/rwrite | -nove/rwrite | -ren/ame] [-pti/me][nombrep ...]
update -add/_loadrules [-print] [-ove/rwrite | -nove/rwrite | -ren/ame][-pti/me] nombrep [...]
Build step 'Execute managed windows batch' marked build as failure
Finished: FAILURE
I've thought in a script that checks if I'm already logged, if not, log in and then update, if yes, only update, and then go on with the compilation, but I don't know how to do that.
Is there any way to do what I want, auto update the CCRC? I can always do it manually, but...you know, it's better non-interactive.
Any suggestions, advice or idea will be helpful.
It depends on the version of ClearCase that you are using.
Before CC 8.0.1.9, there is this bug where, in non interactive mode, IBM ClearCase rcleartool waits on prompt for login when previous login failed, instead of reporting an error and not prompt the user.
As mentioned in this thread, you need to make sure CCSHARED & JAVA_HOME are properly in the rcleartool config.ini, as in here:
CCSHARED=C:\Program Files (x86)\IBM\IMShared
JAVA_HOME=C:\Program Files (x86)\Java\jre7
Those paths are example only, and might differ from your actual path.
The point is: they must be valid in the Jenkins job execution context (on the slave)
The OP Alavaros mentions in the comments:
only updating the version fixed the problem, now I do:
rcleartool update -lname MyUser -server MyServer -password MyPass
And works fine.
"rcleartool update" is ignored because rcleartool.bat itself is a batch file so u have to use "call rcleartool -params args" in each line in your batch file.
Related
I am unable to establish connection to my Oracle database from Azure Databricks although it works in ADF where I am able to query the table. But ADF takes time to filter the records so I am still trying to connect from Databricks.
I followed the steps from this Microsoft link, both manually and using init-script but error seems to persist.
When I looked into my cluster event log it says the init-script execution was successfully.
Error message when I tried to establish the connection:
DPI-1047: Cannot locate a 64-bit Oracle Client library: "/databricks/driver/oracle_ctl//lib/libclntsh.so: cannot open shared object file: No such file or directory".
When I executed the following command
dbutils.fs.ls("/databricks/driver/")
there was no such directory
This triggered me to post some questions here:
Does this mean the init-script did not perform its job?
Is /databricks/driver/oracle_ctl a hidden directory for dbutils.fs.ls?
Error message points to /databricks/driver/oracle_ctl//lib/libclntsh.so, when I manually inspected the downloaded oracle client, there is no such folder called lib although libclntsh.so exists in the main directory. Is there a problem that databricks is checking the wrong directory for the libclntsh.so?
Does this connections still works for others?
Syntax for connection: cx_Oracle.connect(user= user_name, password= password,dsn= IP+':'+Port+'/'+DB_name)
Above syntax works fine when connected from inside a on-premises machine.
Try installing the latest major release of cx_Oracle - which got renamed to python-oracledb, see the release announcement.
This version doesn't need Oracle Instant Client. The API is the same as cx_Oracle, although obviously the name is different.
If I understand the instructions, your init script would do something like:
/databricks/python/bin/pip install oracledb
Application code would be like:
import oracledb
connection = oracledb.connect(user='scott', password=mypw, dsn='yourdbhostname/yourdbservicename')
with connection.cursor() as cursor:
for row in cursor.execute('select city from locations'):
print(row)
Resources:
Home page: oracle.github.io/python-oracledb/
Quick start: Quick Start python-oracledb Installation
Documentation: python-oracle.readthedocs.io/en/latest/index.html
PyPI: pypi.org/project/oracledb/
Source: github.com/oracle/python-oracledb
Upgrading: Upgrading from cx_Oracle 8.3 to python-oracledb
Changed the path from "/databricks/driver/oracle_ctl/" to "/databricks/driver/oracle_ctl/instantclient" in the init-script and that error does not appear anymore.
Please use the following init script instead
dbutils.fs.put("dbfs:/databricks/<init-script-folder-name>/oracle_ctl.sh","""
#!/bin/bash
sudo apt-get install libaio1
wget --quiet -O /tmp/instantclient-basiclite-linuxx64.zip https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip
unzip /tmp/instantclient-basiclite-linuxx64.zip -d /databricks/driver/oracle_ctl/
mv /databricks/driver/oracle_ctl/instantclient* /databricks/driver/oracle_ctl/instantclient
sudo echo 'export LD_LIBRARY_PATH="/databricks/driver/oracle_ctl/instantclient/"' >> /databricks/spark/conf/spark-env.sh
sudo echo 'export ORACLE_HOME="/databricks/driver/oracle_ctl/instantclient/"' >> /databricks/spark/conf/spark-env.sh
""", True)
Notes:
The above init-script was advised by a databricks employee and can be found here.
As mentioned by Christopher Jones in one of the comments, cx_Oracle has been recently upgraded to oracledb with a thin and thick version.
You will get the above error if you don’t have Oracle instant client in your Cluster.
To resolve above error in azure databricks, please follow this code:
%sh
mkdir -p /opt/oracle
cd /opt/oracle
wget https://download.oracle.com/otn_software/nt/instantclient/19600/instantclient-basic-windows.x64-19.6.0.0.0dbru.zip
unzip instantclient-basic-windows.x64-19.6.0.0.0dbru.zip
set ORACLE_HOME=%ORABAS%\instantclient_19_3
set TNS_ADMIN=%ORACLE_HOME%
set PATH=%ORACLE_HOME%;%PATH%
To create init script, use the following code:
As per official doc,
dbutils.fs.put("dbfs:/databricks/<init-script-folder>/oracle_ctl.sh","""
#!/bin/bash
wget --quiet -O /tmp/instantclient-basiclite-linuxx64.zip https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip
unzip /tmp/instantclient-basiclite-linuxx64.zip -d /databricks/driver/oracle_ctl/
sudo echo 'export LD_LIBRARY_PATH="/databricks/driver/oracle_ctl/"' >> /databricks/spark/conf/spark-env.sh
sudo echo 'export ORACLE_HOME="/databricks/driver/oracle_ctl/"' >> /databricks/spark/conf/spark-env.sh
""", True)
To read data from oracle database in PySpark follow this article by Emrah Mete
For more information refer this official document:
https://docs.databricks.com/data/data-sources/oracle.html#oracle
I got an error during the call to a file called by powershell.exe on WINDOWS.
I try to push on GitLab repo.
The code it's inside a script (see below).
I call it from SQL SERVER JOB
----------- the code -------------
$DTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$Msg = ("Auto from SQL job on '" + $DTime + "'")
cd "B:\Instances"
git pull
git add --all
git commit -m $Msg
git push origin master
This is the error:
fatal: Unable to persist credentials with the 'wincredman' credential store.
See https://aka.ms/gcm/credstores for more information.
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://xxx.xxx.it': No such file or directory
I understand is something related to WINDOWS and authentication... but I can't find a solution.
Using "Git bash" calling with the same user of the SQL SERVER JOB, all run fine, also because I run it with the users I need. For the SQL SERVER JOB I got a proxy user (same of the call via "Git Bash").
I tried aldo with "Windows Credential Manager" to re-insert user and password but I'm always front to this wall. How is it possible to call from sql server JOB not powershell but directly my "Git Bash"? I'm not an expert of powershell and this kind of call.
This is the path to my "C:\Program Files\Git\git-bash.exe"....
I would like to sostitute the step below... but Git Bash can receive en external file like arguments... like the one that I use with PowerShell?
powershell.exe -File "C:\Dbatools\GitLab_Push.ps1"
Thak to anyone can give me the right advice.
Alen Italy.
I installed snowsql-1.2.17-windows_x86_64.msi from the installer. After install, I am getting the
below error when calling the below command. please advice
snowsql -a XXXXXXX -u YYYYYY
Installing version: 1.2.17 [####################################] 100%
snowsql bootstrap could not verify the signature for the downloaded file. This snowsql command is not legitimate code. Enable the debug log -o log_level=DEBUG.
Failed to download snowsql. Check network connectivity: 1.2.17
I think it's because SnowSQL is trying to automatically update to the latest version but the signature file is still from the installed version.
In your config file under options, add noup=True (default is false which means update when available), and try again. Haven't tested this, but I think you can also add an option on the launch like this:
snowsql -a XXXXXXX -u YYYYYY --noup
Based on Nick's answer, this seems like a bug so let's hope we don't see these errors going forward.
Open cmd as administrator. Execute the command:
snowsql --noup
Close the window and now run snowsql as administrator. It should open, show a bunch of options and close automatically. Your snowsql should run fine now.
Snowflake reviewed the issue and found that the signature file was incorrect. It has been replaced with a correct signature file and you should not see this issue going forward.
I have the following capistrano 3 task:
desc 'Add root scheduled tasks'
task :root_schedules do
on roles(:all) do
within release_path do
execute :sudo, :bundle, 'exec whenever -w config/root_schedule.rb -u root'
end
end
end
I need this task to run with sudo privileges because I need the scheduled tasks to run with higher privileges. These are backend scheduled server tasks. Problem is that everytime I run this command I get following:
DEBUG [46d3800c] [sudo] password for [user]
After I type my password and hit enter, it never completes anything. No response at all. Any answers out there?
I just created a gem for this purpose: sshkit-sudo
Add gem 'sshkit-sudo' to Gemfile
Add require 'sshkit/sudo' to Capfile
Now you can use sudo command in your Capistrano 3 task.
Capistrano kinda expects you to have this handled with a sudoers file, link so that password input is not required.
The direct answer to the question is: capistrano probably uses the default non-login, non-interactive shell. Since the shell is non-interactive, that probably explains why user input is ignored.
Read more about this here.
I am using Jenkins on a Windows7 system. I would like to use it to execute a batch script on a remote Windows system. The batch script will be used to flash a development board and run some tests. I came across psexec.exe. That works well through a command prompt window--I can connect and run the script without any issues, but when I try to have Jenkins do it, I get the following output:
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
The handle is invalid.
Connecting to ABCDEFG...
Couldn't access ABCDEFG:
Connecting to ABCDEFG...
Build step 'Execute Windows batch command' marked build as failure
The command I am using in both cases is:
psexec.exe \\ABCDEFG -u "DOMAIN\username" -p "password" "C:\test.bat"
The user associated with username has administrator privileges on the remote system (ABCDEFG is not the real name of the system).
Can anyone help me figure out why it is not working through Jenkins? Or, is there an easier/better way to execute a batch script on a remote Windows system through Jenkins?
Thanks to all your help, especially Technext, I have a solution.
I needed run "services.msc", find "Jenkins", right click on it, and go to "Properties". Once the properties windows appeared, I had to click the "Stop" button to stop Jenkins, open the "Log On" tab, enter in my username and password (the username I used when running through command prompt), and start Jenkins again. That got rid of the "handle is invalid" message in Jenkins.
Update:
A better solution was to go onto the system I was using psexec.exe to get onto, go to Control Panel > User Accounts > Give other users access to this computer. Click on "Add..." and type in the username and domain Jenkins uses to run its commands (to find this, open your Jenkins in a browser window, go to Manage Jenkins > System Information and look for USERNAME and USERDOMAIN under Environment Variables). Make sure you give it Administrator rights. Then click ok. Now psexec.exe shouldn't have the "handle is invalid" issue.
Sorry, I don't have enough reputation for comments, but is the single \ a typo? Since
The handle is invalid.
probably means that the computer address is invalid. Try
psexec.exe \\ABCDEFG -u "DOMAIN\username" -p "password" "C:\test.bat"
Notice the two backslashes to access a locally mapped computer.
otherwise if that does not work i recommend the # tag
psexec.exe #servername.txt -u "DOMAIN\username" -p "password" "C:\test.bat"
where #servername.txt is a textfile containing only the servernames, one per line. The file parameter handles the formatting of \
ex servername.txt
ABCDEFG
COMPUTER2
EDIT: also found after some quick googling that it can be related to windows security.
Check out that a simple restart of the remote machine doesn't solve the problem. Also, adding parameters -h and -accepteula may help. Modified command:
psexec.exe \\ABCDEFG -u "DOMAIN\username" -p "password" -h -accepteula "C:\test.bat"
I execute below code from Jenkins pipeline groovy script to connect dynamically created VM as a resource on Jenkins master. Below code connect dynamically created VM as resource on Jenkins master with 4 executors. You can change the number of executors based on your requirement.
bat label: 'ConnectResource', script: """
#echo OFF
C:\\apps\\tools\\psexec \\\\${machine_ip} -u ${machine_ip}\\${machine_username} -p ${machine_password} -accepteula -d -h -i 1 cmd.exe /c "cd C:\\apps\\jenkins\\ & java -jar C:\\apps\\jenkins\\swarm.jar -master http://pnlv6s540:8080 -username ${jenkins_user_name} -password ${jenkins_user_password} -name ${machine_ip}_${BUILD_NUMBER} -labels ${machine_ip}_${BUILD_NUMBER} -deleteExistingClients -disableClientsUniqueId -executors 4" & ping 127.0.0.1 -n 60 > nul
"""