solaris zlogin run command from nosuperuser - solaris

i want execute long running command from global zone in csh shell in zlogin non-interactive mode
zlogin zone1 su - adm /usr/bin/stop_c &
Warning: no access to tty; thus no job control in this shell...
Oracle Corporation SunOS 5.10 Generic Patch January 2005
Badly placed ()'s
logout
Try this but its not helps me
zlogin zone1 su - adm /usr/bin/nohup /usr/bin/stop_c
Warning: no access to tty; thus no job control in this shell...
Oracle Corporation SunOS 5.10 Generic Patch January 2005
^?ELF^A^B^A^B^B^A^A^G≤4: Command not found
Variable syntax
logout

This is the supported way to run a command as a different user with zlogin:
zlogin -l adm zone1 /usr/bin/stop_c &

Related

Why i am not able to install Postgresql (PostgreSQL-9.6.2-2-win64-bigsql.exe)? Windows

I am not able to understand why this happen ?
Log started 07/02/2018 at 14:08:21
Preferred installation mode : win32
Trying to init installer in mode win32
Mode win32 successfully initialized
[14:08:24] Initializing PostgreSQL installer
[14:08:24] Windows Version is: Windows 7 (6.1)
[14:08:24] Operating System Language is: en
[14:08:24] Current build_identifier is: 9.6.2-2
[14:08:24] System PATH:
**All path of my system**
[14:08:24] Initializing pg96 variables
[14:08:24] Download url: https://s3.amazonaws.com/pgcentral
[14:08:24] PostgreSQL Locale to install: DEFAULT
Setting variable windows_net_session_exitcode from C:\Users\himanshu-sharma\AppData\Local\Temp\postgresql_himanshu-sharma/net-session-exit-code.bat
Script exit code: 1
Script output:
Script stderr:
'"C:\Users\HIMANS~2\AppData\Local\Temp\POSTGR~1\NET-SE~1.BAT"' is not recognized as an internal or external command,
operable program or batch file.
Error with configuration or permissions. Please see log file for more information.
Credit to #RAM answer in this . Problems Installing PostgreSQL 9.2
Solution:
Open command prompt in admin mode
Execute following command to change the format based on your drive or all drives
Sample commands:
fsutil 8dot3name set 1
This disable 8dot3 name creation on all volumes
fsutil 8dot3name set C: 1
This disable 8dot3 name creation on c:
Execute the installation as a user having admin privileges
After install, consider resetting the 8dot3name setting to default (2) to avoid unintended consequences
Hope it solves the problem!

How can I start PostgreSQL on Windows?

I have installed Postgresql on my Windows 10 PC. I have used the pgAdmin II tool to create a database called company, and now I want to start the database server running. I cannot figure out how to do this.
I have run the start command on the postgres command line, and nothing seems to happen.
What I doing is:
postgres=# pg_ctl start
postgres=# pg_ctl status
postgres=# pg_ctl restart
postgres=# pg_ctl start company
postgres=# pg_ctl status
.....-> I am seeing nothing returned.
Go inside bin folder in C drive where Postgres is installed.
run following command in git bash or Command prompt:
pg_ctl.exe restart -D "<path upto data>"
Ex:
pg_ctl.exe restart -D "C:\Program Files\PostgreSQL\9.6\data"
Another way:
type "services.msc" in run popup(windows + R).
This will show all services running
Select Postgres service from list and click on start/stop/restart.
Thanks
pg_ctl is a command line (Windows) program not a SQL statement. You need to do that from a cmd.exe. Or use net start postgresql-9.5
If you have installed Postgres through the installer, you should start the Windows service instead of running pg_ctl manually, e.g. using:
net start postgresql-9.5
Note that the name of the service might be different in your installation. Another option is to start the service through the Windows control panel
I have used the pgAdmin II tool to create a database called company
Which means that Postgres is already running, so I don't understand why you think you need to do that again. Especially because the installer typically sets the service to start automatically when Windows is started.
The reason you are not seeing any result is that psql requires every SQL command to be terminated with ; in your case it's simply waiting for you to finish the statement.
See here for more details: In psql, why do some commands have no effect?
If you have installed postgres via the Windows installer you can start it in Services like so:
After a lot of search and tests i found the solution :
if you are in windows :
1 - first you must found the PG databases directory
execute the command as sql command in pgAdmin query tools
$ show data_directory;
result :
------------------------
- D:/PG_DATA/data -
------------------------
2 - go to the bin directory of postgres in my case it's located "c:/programms/postgresSql/bin"
and open a command prompt (CMD) and execute this command :
pg_ctl -D "D:\PSG_SQL\data" restart
This should do it.
The simplest way to start/stop/restart the installed PostgreSQL Server on your Windows device is as follows:
Start -> net start postgresql-x64-14
Stop -> net stop postgresql-x64-14
Restart -> net stop postgresql-x64-14 && net start postgresql-x64-14
The version number must be changed to take into account the installed version of your PostgreSQL Server.
For windows the following command worked well for me
pg_ctl.exe restart -D "<path_to_data>"
Eg: pg_ctl.exe restart -D "D:\Program Files\PostgreSQL\13\data"
If you are getting an error "psql.exe' is not recognized as an internal or external command,... "
There can be :
Causes
System is unable to find the psql.exe tool, because the path to this tool is not specified in the system environment variable PATH
or
- PostgreSQL Database client not installed on your PC
Since you have already installed PostgreSQL the latter can not be the issue(assuming everything is installed as expected)
In order to fix the first one "please specify the full path to the bin directory in the PostgreSQL installation folder, where this tool resides."
For example
Path: "C:\Program Files\PostgreSQL\10\bin"
I found using
net start postgres_service_name
the only reliable way to operate Postgres on Windows
first find your binaries file where it is saved.
get the path in terminal mine is
C:\Users\LENOVO\Documents\postgresql-9.5.21-1-windows-x64-binaries
(1)\pgsql\bin
then find your local user data path, it is in mostly
C:\usr\local\pgsql\data
now all we have to hit following command in the binary terminal path:
C:\Users\LENOVO\Documents\postgresql-9.5.21-1-windows-x64-binaries (1)\pgsql\bin>pg_ctl -D "C:\usr\local\pgsql\data" start
all done!
autovaccum launcher started! cheers!
Remove Postmaster file in "C:\Program Files\PostgreSQL\9.6\data"
and restart the PostgreSQL services
There are different way to open PostgreSql database .
1> One of them is by going windows and select pgAdmin4 or pgAdmin3 depends to version you use and entering password you can access you database .
2> Another one is by terminal :
To able to select from terminal you have to add the path of your installed postgresql by going enviroment variables . To do that got to installed postgresql file and select the path of bin and add to enviroment variable of window setting .
after that you can type in terminal : psql -U postgres -h localhost
Hit enter and it ask you password . After giving password you can create database and tables and can access it .
I was try to solve the problem with Windows Terminal and I've cannot to solve it. Use Windows R + cmd (if you are using Windows) for it work!
The easiest way to enable pg_ctl command is to go to your PostgreSQL directory ~\PostgreSQL\version\bin\ and execute the pg_ctl.exe. Afterwards the pg_ctl commands will be available.

make check fails to start in Postgres 8.4.2

I am running into a strange error when trying to run PostgreSQL 8.4.2's regression suite on a new Ubuntu instance that I've created on Amazon EC2.
I can configure PostgreSQL successfully:
$ ./configure
[ Output not shown ]
$ tail -1 config.log
configure: exit 0
It builds just fine:
$ make
[ Ouput clipped ]
All of PostgreSQL successfully made. Ready to install.
But when I try to run the regression suite, I receive an error:
$ make check
[ Ouput clipped ]
make[2]: Entering directory `/home/ubuntu/stock/postgresql-8.4.2/src/test/regress'
You must use GNU make to use Postgres. It may be installed
on your system with the name 'gmake'.
However, I believe that I am running GNU Make:
$ make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-pc-linux-gnu
$ ls -l `which gmake`
lrwxrwxrwx 1 root root 13 Feb 6 17:41 /usr/bin/gmake -> /usr/bin/make
I see that in the src/test/regress directory, there is a Makefile:
$ cat src/test/regress/Makefile
# The Postgres make files exploit features of GNU make that other makes
# do not have. Because it is a common mistake for users to try to build
# Postgres with a different make, we have this make file that does nothing
# but tell the user to use GNU make.
# If the user were using GNU make now, this file would not get used because
# GNU make uses a make file named "GNUmakefile" in preference to "Makefile"
# if it exists. Postgres is shipped with a "GNUmakefile".
all install clean check installcheck:
#echo "You must use GNU make to use Postgres. It may be installed"
#echo "on your system with the name 'gmake'."
The comments in that Makefile indicate that there should be a file named GNUmakefile in that directory, but there is not:
$ ls src/test/regress/*akefile
src/test/regress/Makefile
There is a GNUMakefile in the top-level directory:
$ ls *akefile
GNUmakefile Makefile
Even when I force make and make check to use the GNUmakefile, via -f GNUmakefile, the same error occurs.
Note that I can run the regression suite just fine on my home machine.
Does any one have any ideas why it's not working on the EC2 instance?
EDIT: On my home machine, I'm running Ubuntu 12.04. The EC2 instance is running 13.10. Both machines are running make version 3.81.
You must have a messed up download or checkout. There should be a src/test/regress/GNUmakefile there, as you suspected. Try downloading again.
This is what that directory looks like on mine:
$ ls src/test/regress/*akefile
src/test/regress/GNUmakefile src/test/regress/Makefile

Permanently enable RHEL scl

Is there a way to permanently enable custom Software Collections for RedHat?
I have installed an scl to provide python27 in RHEL6 and don't want to have to enable the custom scl every time.
Well, you could add something to your startup script to source the enable script.
Eg add to your .bash_profile (note space between initial dot and /)
. /opt/rh/python27/enable
This option sounds dangerous to me for root. I would think something like the following would be safer and more appropriate:
You can create a function that takes command line options. Think of this as an alias on steroids. Add the following to your .bashrc
python27() {
scl enable python27 “python $*”
}
Then test:
python27 –version
Python 2.7.5
This doesn’t help with your magic line in scripts, but will make it easier to call scripts:
[smccarty#keith ~]$ cat script.py
#!/usr/bin/env python27
import sys
print “Hello, World!”, sys.version
Call it normal and notice, the default installation of python is used:
[smccarty#keith ~]$ ./script.py
Hello, World! 2.6.6 (r266:84292, Sep 4 2013, 07:46:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
Call it with our alias, and notice that Python 2.7 is used:
[smccarty#keith ~]$ python27 script.py
Hello, World! 2.7.5 (default, May 23 2013, 06:08:09)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
In a nutshell: source scl_source enable name
to find the name you can do scl --list
longer story:
In your ~/.bashrc or ~/.bash_profile or /etc/profile.d/enable_name.sh
if command -v scl_source &>/dev/null; then
source scl_source enable name
fi
Hat tip to:
solution in unix.stackexchange.com
solution in serverfault.com
solution in redhat.com
p.s. do not use any solution that spawns a new shell because it can Forkbomb you and prevent you from being able to login
for more information on avoiding the ForkBomb read here1 and here2
p.s. SCL goes away in EnterpriseLinux version >= el8

Perl Net::SSH::Perl not loading my environment variables vs connecting through SSH

My problem is connecting throguh Net::SSH::Perl vs Connecting through SSH.
my shell variables ( command: export ) aren't the same.
This fact prevents me from executing user's script that depends on the shell env vars.
For example:
if i execute through perl ( Net::SSH::Perl ) the command: "export" I get:
MAIL=/var/mail/username
PATH=/usr/local/bin:/bin:/usr/bin
PWD=/username
SHELL=/bin/ksh
SSH_CLIENT='myIPAddress 1022 22'
SSH_CONNECTION='myIPAddress 1022 remoteIPAddress 22'
USER=myusername
while executing the same command through regular ssh connecting I get 42 rows of ENV VARS.
Other example:
if i execute through perl ( Net::SSH::Perl ) the command: "tty" I get:
not a tty
while executing the same command through regular ssh connecting I get:
/dev/pts/3
What am I missing here ?
For the environment variables, it sounds like ~/.bashrc isn't getting sourced. You should be able to source it yourself:
$ssh->cmd(". ~/.bashrc");
For the terminal, allocating a pty is not necessary for many tasks, so it is not normally done for non-interactive shells; however, you can pass the use_pty option when creating your ssh object to tell it to create a pty.
from the Net::SSH::Perl documentation:
use_pty
Set this to 1 if you want to request a pseudo tty on the remote machine. This is really only useful if you're setting up a shell connection (see the shell method, below); and in that case, unless you've explicitly declined a pty (by setting use_pty to 0), this will be set automatically to 1. In other words, you probably won't need to use this, often.
The default is 1 if you're starting up a shell, and 0 otherwise.
Chas, that would not work either as Net::SSH::Perl (and for that matter, most other Perl SSH clients) runs every command in a new shell session, and so side effects do not persist between commands.
The solution is to combine both commands as follows:
$ssh->cmd(". ~/.bashrc && $cmd");