weblogic.Admin: command not found - weblogic

I am using linux terminal with below code to get server status but i am getting weblogic.Admin: command not found, any lead would be appreciable.
cd /opt/SP/WEB_DATA/weblogic/wls12130/user_projects/domains/pega/bin
. ./setDomainEnv.sh
export CLASSPATH=/WEB_DATA/weblogic/wls12130/wlserver/server/lib/weblogic.jar
ServerState=/opt/SP/WEB_DATA/mw/jdk1.8.0_91/bin/java weblogic.Admin -url http://t3://localhost:7001 -username weblogic -password weblogic1
GET -pretty -type ServerRuntime -property State |grep -i State|awk '{print $2}'| rev | cut -c 1- | rev

weblogic.Admin has been deprecated for a while now. Use wlst instead.
(location of ORACLE_HOME)/wlserver/common/bin/wlst.sh
wls:/offline>connect('weblogic','weblogic1','t3://localhost:7001')
wls:/DOMAIN/serverConfig>state('WLAdmin','Server')
WLAdmin is the name of the admin server
You can place the above commands in a python script and execute it using wlst

Related

SSH Permission Denied WindowsPowerShell

I'm trying to connect to my Jetsonnano from Windows 10 via ssh. If i use my Ubuntu Pc everything works fine, but if i use my Windows 10 Laptop I see this Error:
Permission denied, please try again.
After I type in the correct Password.
Thank you all for your Time and Help
Check for the pwsh executable path first:
Get-Command pwsh | select Source
this will give you the path of powershell core path
Get-Command powershell | select Source
this command on the other hand will return the path of earlier version of powershell
i.e. powershell version 5 etc.
I was also having the same issue. After I blindly copied a command from a blog post and executed it:
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell
-Value "C:\Program Files\PowerShell\7\pwsh.exe" -PropertyType String -Force
I scratched my head for more than 10 hours.
then I did debug run of sshd with this command on Windows 10 host:
sshd -d
and tried to connect from my Linux machine as usual:
ssh james#192.168.1.123
I saw this line in my Windows debug prompt:
User james not allowed because shell c:\\program files\\powershell\\7\\pwsh.exe does not exist
so I executed this command again with modified path to Powershell 7 executable:
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell
-Value "C:\Program Files\WindowsApps\Microsoft.PowerShell_7.2.1.0_x64__8wekyb3d8bbwe\pwsh.exe"
-PropertyType String -Force
and it fixed my problem.
Open the terminal
start ssh-agent eval$(ssh-agent -s)
add a key to the ssh-agent (if prompted, enter the password)
ssh-add ~/.ssh/id_rsa
test connection ssh -T git#github.com
Clone the repo git clone git#github.com:antonykidis/Setup-ssh-for-github.git
Enjoy
Important:
Every time you start a new Terminal instance:
You will have to call ssh-agent.
Add RSA key to the ssh-agent.
Loop through these steps every time you close/open the terminal.
Because the terminal “loses” ssh-agent with its keys on every session.
Check this information:
Open C:\Program Files\Git\etc\ssh\ssh_config (if that’s where you installed Git)
Add lines
Host github.com or ubuntu host machine
IdentityFile ~/.ssh/

How to disable bash info prints

Im running the next postgres query using the next bash command.
sudo -u postgres bash -c "psql -d db -c \"SELECT ip FROM db_accounts;\"" \>/dev/null
The output is a table but before the table is printed, I get the following info prints
> psql: /usr/lib64/libssl.so.10: no version information available
> (required by psql) psql: /usr/lib64/libcrypto.so.10: no version
> information available (required by /usr/pgsql-9.4/lib/libpq.so.5)
> psql: /usr/lib64/libssl.so.10: no version information available
> (required by /usr/pgsql-9.4/lib/libpq.so.5)
I want to run my command without these prints appearing.
I tried to change the end of the command >/dev/null to 2>/dev/null and indeed the prints were disable but my table was not fully displayed (out of 800 rows only 40 were displayed),
Can someone help me please?
Use --quiet when you start psql
OR
It can be set in your postgresql.conf file by adding this
client_min_messages = warning
This blog is really helpful.
To fix want I wanted I added --pset pager=off to the psql to get the whole table and the disable the prints I change the end of the command to 2>/dev/null
final command:
sudo -u postgres bash -c "psql --pset pager=off --quiet -d db -c \"SELECT ip FROM db_accounts;\"" 2>/dev/null

Unattended signing of Reprepro packages with gpg-agent

For my SolydXK repository I'd like to add some packages available in Debian stretch-backports.
I've successfully setup the conf/distributions, conf/updates and FilterList files and the following command runs successfully when logged in to the server:
reprepro -b /path_to_repository_basedir update
When adding files to the repository I correctly have to fill in my gpg passphrase to sign the files. During the session I only have to do that once.
Now I've tried to make the signing unattended by creating this script that's called from my .bash_profile:
#!/bin/sh
OURKEY=ABCDEFGH
PASSPHRASE=my_passphrase
PIDOF=`pidof gpg-agent`
RETVAL=$?
# Decide wether to start gpg-agent daemon.
if [ "$RETVAL" -eq 1 ]; then
echo "Starting gpg-agent daemon."
eval `gpg-agent --allow-preset-passphrase --allow-mark-trusted --default-cache-ttl-ssh 4294967295 --default-cache-ttl 4294967295 --max-cache-ttl 4294967295 --daemon --enable-ssh-support --write-env-file "${HOME}/.gpg-agent-info"`
else
echo "Daemon gpg-agent already running."
fi
if [ -f "${HOME}/.gpg-agent-info" ]; then
. "${HOME}/.gpg-agent-info"
export GPG_AGENT_INFO
export SSH_AUTH_SOCK
export SSH_AGENT_PID
# Create necessary symbolic link
cp -fs `echo $GPG_AGENT_INFO | cut -d':' -f 1` "${HOME}/.gnupg/"
fi
# Default trust our own key
rm ~/.gnupg/trustlist.txt
for FP in $(gpg2 --fingerprint --with-colons --fingerprint $OURKEY | grep ^fpr | cut -d':' -f 10); do
echo "$FP S" >> ~/.gnupg/trustlist.txt
echo $PASSPHRASE | /usr/lib/gnupg2/gpg-preset-passphrase --preset $FP
done
# Set GPG TTY
export GPG_TTY=$(tty)
I checked the fingerprints (a.k.a. keygrip, but this version of gpgsm does not know the --with-keygrip option) and all seems to be alright. However, when a cron job runs the above update command, an error message states that the passphrase is incorrect.
The server runs on Debian old-squeeze (I know, I have to do something about that, but that's another problem) and that might be a big problem. Here's some version info:
cat /etc/debian_version
6.0.10
uname -r
3.14.52-vs2.3.6.15-1
gpg (GnuPG) 1.4.10
gpg (GnuPG) 2.0.14
gpgsm (GnuPG) 2.0.14
gpg-agent (GnuPG) 2.0.14
So, is there somebody here who has some experience with unattended signing of packages with gpg-agent and can explain to me what I'm doing wrong?

Error in Mysqldump command

I have a data base named "mig". it has 10 tables. now i want to create a same database in another system so I am using mysqldump command but it shows error.
I entered command as follows :
mysqldump -u root -p root mig >file.sql;
This is the error i got :
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'mysql
dump -u root -p root mig >file.sql' at line 1
I am getting the same error when I use ,
mysqldump -u root -proot mig >file.sql;
How can i fix this ?
Simply try-
mysqldump -u root mig> file.sql
Edit
mysqldump is not a MySQL command, it is a command line utility. You must call it from your shell command line. I hope you are not calling this from MySQL prompt.
When providing password on the command line you should leave no space after -p.
It should look smth like:
mysqldump -u root -proot mig >file.sql;
You can use some tools like MySQL Workbench or SQLyog to import the dump file.
Free version: https://code.google.com/p/sqlyog/wiki/Downloads
When you execute mysqldump from command line, you must have mysql_home/bin directory in your classpath variable or command-line must be pointing to it.
try using
mysqldump -u root -proot mig >(abs_path)/file.sql;
This works for me on my local. Open Terminal and execute the following code (Make sure your are NOT on the MySQL prompt):
mysqldump -uroot -p mig > file.sql
It will ask you to input the password on the next line, for security the password won't be shown.
If you get Access Denied, means the mysql credentials are wrong (or the user you use don't have the right permissions to generate a dump), so make sure you have a valid username and password. I hope it helps.
mysqldump will not run from mysql cli, you will have to run it from windows command prompt:
mysqldump -u username -p database_name > output_file_name.sql;
If you are getting error on running above command 'mysqldump is not recognized as an internal or external command' then navigate to < MySQL Installation Directory/bin/ > and then run the command.
i have the same problem, my situation was i connect from client in local computer to server in SQL instance of Google. Since i read Sahil Mittal said this is comman utilty, i just put in terminal the same command adding -h parameter.
mysqldump -h ip.del.host -u root -p database_name > database_desired_name.sql

Piping password to smbpasswd

How can I pipe the new password to smbpasswd so I can automate my installation process.
Thanks to Mark I found the answer:
(echo newpassword; echo confirmNewPassword) | smbpasswd -s
BTW: (echo oldpasswd; echo newpasswd) | smbpasswd -s does not work.
I use the following in one of my scripts:
echo -ne "$PASS\n$PASS\n" | smbpasswd -a -s $LOGIN
With echo:
-e : escape sequences, like \n
-n : don't add implicit newline at end
With smbpasswd:
-a : add new user
-s : silent
Try something like this:
(echo oldpasswd; echo newpasswd) | smbpasswd -s
Use this
echo 'somepassword' | tee - | smbpasswd -s
I had to create a new Samba user in a Puppet 5.x Exec resource and for various reasons none of the above worked. Fortunately this rather silly-looking command worked:
yes vagrant|head -n 2|smbpasswd -a -s vagrant
Password here is of course "vagrant".
This unfortunately is not desirable for two reasons:
1) if the user uses a combination of '\n' in the password there will be a mismatch in the input
2) if there are unix users on the system, then a user using the utility ps may see the password
A better way would be to put the names in a file and read from the file and use python pexpect to read them, not like below, but the simple script is enough to see how to use pexpect
#!/usr/bin/python
#converted from: http://pexpect.sourceforge.net/pexpect.html
#child = pexpect.spawn('scp foo myname#host.example.com:.')
#child.expect ('Password:')
#child.sendline (mypassword)
import pexpect
import sys
user=sys.argv[1]
passwd=sys.argv[2]
child = pexpect.spawn('/usr/bin/smbpasswd -a '+str(user))
child.expect('New SMB password:')
child.sendline (passwd)
child.expect ('Retype new SMB password:')
child.sendline (passwd)
then try: ./smbpasswd.py userName1 'f##(&*(_\n895'
using either pipelines or redirection.