My default shell is Bash and I am on directory /opt/app/IRMS and execute a script /opt/app/depl/bin/runjob.sh. Runall exists and is a soft link.
I get the following error :
[tidal#atlesapp002 IRMS]$ ksh -x /opt/app/depl/bin/runjob.sh execute
ls irms_inq.env
+ myenv=irms_inq.env
+ . ./irms_inq.env
+ . /home/tidal/cfg/setenv
+ export PATH
+ export LD_LIBRARY_PATH
+ export FPATH
+ export SQLPATH
+ PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/tidal/bin:.
+ . /home/tidal/cfg/python.env
+ PY=/opt/python
+ PATH=/opt/python/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/tidal/bin:.
+ LD_LIBRARY_PATH=:/opt/python/lib
+ . /home/tidal/cfg/svn.env
+ SVN=/opt/app/svn
+ PATH=/opt/app/svn/bin:/opt/python/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/tidal/bin:.
+ LD_LIBRARY_PATH=/opt/app/svn/lib::/opt/python/lib
+ . /home/tidal/cfg/ora.env
+ CLI=/opt/app/instantclient_11_2
+ NLS_LANG=AMERICAN_AMERICA.UTF8
+ export NLS_LANG
+ LD_LIBRARY_PATH=/opt/app/instantclient_11_2:/opt/app/svn/lib::/opt/python/lib
+ export LD_LIBRARY_PATH
+ TNS_ADMIN=/opt/app/instantclient_11_2
+ export TNS_ADMIN
+ PATH=/opt/app/svn/bin:/opt/python/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/tidal/bin:.:/opt/app/instantclient_11_2
+ export PATH
+ . /home/tidal/cfg/depl.env
+ DEPL=/opt/app/depl
+ PATH=/opt/app/svn/bin:/opt/python/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/tidal/bin:.:/opt/app/instantclient_11_2:/opt/app/depl/bin
+ FPATH=:/opt/app/depl/lib
+ SQLPATH=:/opt/app/depl/lib
+ . /home/tidal/cfg/putils.env
+ PATH=/opt/app/svn/bin:/opt/python/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/tidal/bin:.:/opt/app/instantclient_11_2:/opt/app/depl/bin:/opt/app/putils/bin
+ SQLPATH=:/opt/app/depl/lib:/opt/app/putils/lib
+ pwd
+ irmspwd=/opt/app/IRMS
+ PATH=/opt/app/svn/bin:/opt/python/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/tidal/bin:.:/opt/app/instantclient_11_2:/opt/app/depl/bin:/opt/app/putils/bin:/opt/app/IRMS/bin
+ SQLPATH=:/opt/app/depl/lib:/opt/app/putils/lib:/opt/app/IRMS/lib
+ SQLPATH=:/opt/app/depl/lib:/opt/app/putils/lib:/opt/app/IRMS/lib:/opt/app/IRMS/src
+ runall execute
/opt/app/depl/bin/runjob.sh[7]: runall: not found [No such file or directory]
[tidal#atlesapp002 IRMS]$
====
[tidal#atlesapp002 bin]$ ls -al
total 96
drwxrwxr-x 3 tidal tidal 4096 Jun 9 13:29 .
drwxrwxr-x 4 tidal tidal 4096 May 19 16:38 ..
lrwxrwxrwx 1 tidal tidal 8 Jun 8 12:56 runall -> setup.sh
-rwxr-xr-x 1 tidal tidal 2319 May 19 16:38 runall.save
-rwxr-xr-x 1 tidal tidal 831 May 19 16:38 runcp.sh
-rwxr-xr-x 1 tidal tidal 54 Jun 9 13:29 runjob.sh
-rwxr-xr-x 1 tidal tidal 2242 May 19 16:38 runsockets.pl
lrwxrwxrwx 1 tidal tidal 9 Jun 9 00:01 runsql -> runsql.sh
-rwxr-xr-x 1 tidal tidal 1877 May 19 16:38 runsql.save
-rwxr-xr-x 1 tidal tidal 1877 May 19 16:38 runsql.sh
-rwxr-xr-x 1 tidal tidal 5590 May 19 16:38 setParm.pl
-rwxr-xr-x 1 tidal tidal 2319 May 19 16:38 setup.sh
It seems runall started from $PATH and not from current directory ./runall, since /opt/app/IRMS/bin was added to the $PATH.
Try the following:
start ksh [tidal#atlesapp002 IRMS]$ ksh
run /opt/app/depl/bin/runjob.sh execute
If this does not help try adding /opt/app/IRMS/bin to PATH and then export PATH
Yes when I added ksh to the runall script it worked.
like ksh runall
Why ?
Related
I wrote a python code like:
#!/usr/bin/python
import os
import sys
f=open("/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements/statement/guru99.txt","w+")
i tried to create file on mounted drive (on AIX)
node mounted
-------- --------------- --------------- ------ ------------ ---------------
clsfs038 /Bank_statements /inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements
...and i got error:
OSError: [Errno 22] Invalid argument: '/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements/statement/guru99.txt'
same code for local path is working ok!
I create file on mounted drive by bash without any problem.
It's df:
[inform#xxx/inform ] $ df
Filesystem 512-blocks Free %Used Iused %Iused Mounted on
/dev/hd10opt 1966080 380432 81% 15329 24% /opt
/dev/livedump 65536 64864 2% 4 1% /var/adm/ras/livedump
/dev/informlv 1257766912 662083576 48% 425081 1% /inform
clsfs038:/Bank_statements 2576863224 393165352 85% 0 0% /inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements
permission on folder:
[inform#xxx /inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements ] $ ls -la
total 184
drwxrwxr-x 1 inform inform 16384 Dec 19 16:44 .
drwxr-xr-x 19 inform inform 32768 Dec 18 17:16 ..
drwxrwxr-x 1 inform inform 16384 Dec 19 14:08 load
drwxrwxr-x 1 inform inform 16384 Dec 19 10:37 statement
-rwxrwxr-x 1 inform inform 0 Nov 22 12:26 testfile
-rwxrwxr-x 1 inform inform 0 Dec 18 13:06 testfile2
Mount:
[inform#xxx /inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements ] $ mount
node mounted mounted over vfs date options
-------- --------------- --------------- ------ ------------ ---------------
/dev/hd4 / jfs2 Aug 26 17:39 rw,log=/dev/hd8
/dev/hd2 /usr jfs2 Aug 26 17:39 rw,log=/dev/hd8
/dev/hd9var /var jfs2 Aug 26 17:39 rw,log=/dev/hd8
/dev/hd3 /tmp jfs2 Aug 26 17:40 rw,log=/dev/hd8
/dev/hd1 /home jfs2 Aug 26 17:40 rw,log=/dev/hd8
/dev/hd11admin /admin jfs2 Aug 26 17:40 rw,log=/dev/hd8
/proc /proc procfs Aug 26 17:40 rw
/dev/hd10opt /opt jfs2 Aug 26 17:40 rw,log=/dev/hd8
/dev/livedump /var/adm/ras/livedump jfs2 Aug 26 17:40 rw,log=/dev/hd8
/dev/informlv /inform jfs2 Aug 26 17:40 rw,log=INLINE
/dev/zabbixapplv /opt/zabbixapp jfs2 Aug 26 17:40 rw,log=INLINE
clsfs042 /sap_employee /inform/app/Informatica/10.1.0/server/infa_shared/SrcFiles/SAP cifs Aug 26 17:40 rw,uid=482,gid=482,fmode=775,wrkgrp=RCCF,noprompt
clsfs042 /Applications /inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/Popcorn/Informatica cifs Aug 26 17:40 rw,uid=482,gid=482,fmode=775,wrkgrp=RCCF,noprompt
clsfs041 /AFS /inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/afs cifs Aug 26 17:40 rw,uid=482,gid=482,fmode=775,wrkgrp=RCCF,noprompt
clsfs038 /DetOtchet /inform/app/Informatica/10.1.0/server/infa_shared/SrcFiles/CB_PORTF cifs Aug 26 17:40 rw,uid=482,gid=482,fmode=775,wrkgrp=RCCF,noprompt
clsfs038 /BALANS /inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/BALANS cifs Aug 26 17:40 rw,uid=482,gid=482,fmode=775,wrkgrp=RCCF,noprompt
clsfs040 /Workgroups /inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/Metodologiya cifs Aug 26 17:40 rw,uid=482,gid=482,fmode=775,wrkgrp=RCCF,noprompt
clsfs038 /Workgroups3 /inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/ALM_REPORT cifs Aug 26 17:40 rw,uid=482,gid=482,fmode=775,wrkgrp=RCCF,noprompt
clsfs042 /Applications /inform/app/Informatica/10.1.0/server/infa_shared/SrcFiles/rccf_applications cifs Nov 12 12:20 rw,uid=482,gid=482,fmode=775,wrkgrp=RCCF
clsfs038 /Bank_statements /inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements cifs Nov 22 12:27 rw,uid=482,gid=482,fmode=775,wrkgrp=RCCF
Result of command (stackoverflow asked me some more details, without this text i cant edit my post with this code):
[inform#xxx /inform/app/Informatica/10.1.0/server/infa_shared/Scripts/STATEMENT ] $ /inform/app/Informatica/10.1.0/server/infa_shared/Scripts/STATEMENT/test/stack.py
False
READ False
WRITE False
/inform True
/inform READ True
/inform WRITE True
/inform/app True
/inform/app READ True
/inform/app WRITE True
/inform/app/Informatica True
/inform/app/Informatica READ True
/inform/app/Informatica WRITE True
/inform/app/Informatica/10.1.0 True
/inform/app/Informatica/10.1.0 READ True
/inform/app/Informatica/10.1.0 WRITE True
/inform/app/Informatica/10.1.0/server True
/inform/app/Informatica/10.1.0/server READ True
/inform/app/Informatica/10.1.0/server WRITE True
/inform/app/Informatica/10.1.0/server/infa_shared True
/inform/app/Informatica/10.1.0/server/infa_shared READ True
/inform/app/Informatica/10.1.0/server/infa_shared WRITE True
/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles True
/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles READ True
/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles WRITE True
/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements True
/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements READ True
/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements WRITE True
/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements/statement True
/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements/statement READ True
/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements/statement WRITE True
/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements/statement/guru99.txt False
/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements/statement/guru99.txt READ False
/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements/statement/guru99.txt WRITE False
Help me please)
Regards,
Alex
Can you paste result of following script ? Just in case it helps find out anything
#!/usr/bin/python
import os
file_name = "/inform/app/Informatica/10.1.0/server/infa_shared/TgtFiles/bank_statements/statement/guru99.txt"
dirs = file_name.split("/")
for i in range(len(dirs)):
dir_to_check = "/".join(dirs[:i+1])
print(dir_to_check + " " + str(os.path.exists(dir_to_check)))
print(dir_to_check + " READ " + str(os.access(dir_to_check, os.R_OK)))
print(dir_to_check + " WRITE " + str(os.access(dir_to_check, os.W_OK)))
I would like to know is it possible to rename a symlink with python.
Already tried os.rename and shutil.move
Any ideas?
os.rename return me this error : OSError: [Errno 18] Cross-device link
>>> import sys, os
>>>
>>> path = '/Library/Application Support/appsolute/MAMP PRO/db/'
>>> job = path + 'mysql-job/'
>>> perso = path + 'mysql-perso/'
>>> mysql = path + 'mysql/'
>>>
>>> os.rename(mysql, job)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 18] Cross-device link
>>> exit()
Danny-Dombrowski:script ddombrowski$ ls -al /Library/Application\ Support/appsolute/MAMP\ PRO/db/
total 24
drwxrwxr-x 5 root admin 170 7 fév 19:29 .
drwxrwxr-x 12 root admin 408 7 fév 17:14 ..
-rw-r--r--# 1 ddombrowski admin 6148 7 fév 19:29 .DS_Store
lrwxr-xr-x 1 ddombrowski admin 46 7 fév 19:29 mysql -> /Volumes/Gestion Portail Sante/Database/mysql/
drwxrwxr-x 11 ddombrowski admin 374 7 fév 19:22 mysql-perso
os.rename should work.
xupeng#xupeng t $ ls -l
total 0
-rw-r--r-- 1 xupeng xupeng 0 Feb 8 08:22 a
lrwxrwxrwx 1 xupeng xupeng 1 Feb 8 08:23 b -> a
xupeng#xupeng t $ python
Python 2.6.5 (release26-maint, Sep 21 2011, 10:32:38)
[GCC 4.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.rename('b', 'c')
xupeng#xupeng t $ ls -l
total 0
-rw-r--r-- 1 xupeng xupeng 0 Feb 8 08:22 a
lrwxrwxrwx 1 xupeng xupeng 1 Feb 8 08:23 c -> a
os.rename will work fine:
$ ln -s target link
$ python -c "import os; os.rename('link', 'link.new')"
$ ls -l link.new
lrwxrwxrwx 1 phihag phihag 6 Feb 8 01:25 link.new -> target
Make sure you don't include a / after the symlink: link/ is the same as link/., and not the same as link.
I'm using paramiko.SSHClient.exec_command() to run commands on remote servers.
Does someone know if it's possible to change the width, like with invoke_shell(width=150) ?
When I exec_command("ls -la") I get :
drwx------. 6 myuser myuser 4096 25 avril 15:59
.
drwxr-xr-x. 14 root root 4096 5 mai 15:05
..
-rw-------. 1 myuser myuser 2818 28 avril 11:09
.bash_history
-rw-r--r--. 1 myuser myuser 340 14 avril 14:16
.bashrc
and I want :
drwx------. 6 myuser myuser 4096 25 avril 15:59 .
drwxr-xr-x. 14 root root 4096 5 mai 15:05 ..
-rw-------. 1 myuser myuser 2818 28 avril 11:09 .bash_history
-rw-r--r--. 1 myuser myuser 340 14 avril 14:16 .bashrc
(using exec_command, not invoke_shell)
My code :
ssh_client = paramiko.SSHClient()
mykey = paramiko.RSAKey.from_private_key_file("/path/to/my/key", password="passphrase")
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect("myserver.mydomain.com", username="myuser", pkey=mykey)
transport = ssh_client.get_transport()
agent_channel = transport.open_session()
agent_handler = paramiko.agent.AgentRequestHandler(agent_channel)
stdin, stdout, stderr = ssh_client.exec_command("ls -la")
Ok, found it: it was just a pprint strange behavior. I put the received lines in a list, and then pprint this list. If I do :
for line in received:
print(line)
Then It's ok.
pprint printed :
['-rw-r----- 1 myuser mygroup 23228063744 06 mai 11:41 '
'my_file.txt-rw-r----- 1 '
...
I don't know why. Well, I'll stop using pprint.
I'm trying to execute command in Python like this:
os.system('ls')
What's interesting is that the output length is limited by the terminal window size where I'm running this python console.
>>>os.system('ls -l')
total 0
-rw-r--r-- 1 hy hy 0 Apr 29 22:30 a.txt
-rw-r--r-- 1 hy hy 0 Apr 29 22:31 b.txt
-rw-r--r-- 1 hy hy 0 Apr 29 22:31 c.txt
-rw-r--r-- 1 hy hy 0 Apr 29 22:31 d.txt
-rw-r--r-- 1 hy hy 0 Apr 29 22:31 e.txt
-rw-r--r-- 1 hy hy 0 Apr 29 22:31 f.txt
-rw-r--r-- 1 hy hy 0 Apr 29 22:31 g.txt
>>>
I did that in a directory containing hundreds of files, and intentionally re-size the terminal window very small, it only outputs very few lines which exactly fill the entire window. If I use smaller terminal window, it output even less lines. Every time it just outputs down to the low boundary of my terminal window.
It's not that python console hides some output when displaying. I tried using subprocess.Popen() to store the output into a pipe and readlines() the pipe, and got the same result.
But it seems python doesn't do that all the time. I don't got this problem on all machines.
I am trying to install postgresql_python.
I downloaded the tarball and installed it using:
python setup.py build
python setup.py install
I got /usr/lib64/python2.4/site-packages/psycopg2/ with
> total 836
> -rw-r--r-- 1 root root 12759 Dec 11 18:18 errorcodes.py
> -rw-r--r-- 1 root root 14584 Dec 12 13:49 errorcodes.pyc
> -rw-r--r-- 1 root root 14584 Dec 12 13:49 errorcodes.pyo
> -rw-r--r-- 1 root root 5807 Dec 11 18:18 extensions.py
> -rw-r--r-- 1 root root 7298 Dec 12 13:49 extensions.pyc
> -rw-r--r-- 1 root root 7298 Dec 12 13:49 extensions.pyo
> -rw-r--r-- 1 root root 31495 Dec 11 18:18 extras.py
> -rw-r--r-- 1 root root 35124 Dec 12 13:49 extras.pyc
> -rw-r--r-- 1 root root 35124 Dec 12 13:49 extras.pyo
> -rw-r--r-- 1 root root 6177 Dec 11 18:18 __init__.py
> -rw-r--r-- 1 root root 5740 Dec 12 13:49 __init__.pyc
> -rw-r--r-- 1 root root 5740 Dec 12 13:49 __init__.pyo
> -rw-r--r-- 1 root root 8855 Dec 11 18:18 pool.py
> -rw-r--r-- 1 root root 8343 Dec 12 13:49 pool.pyc
> -rw-r--r-- 1 root root 8343 Dec 12 13:49 pool.pyo
> -rw-r--r-- 1 root root 3389 Dec 21 11:17 psycopg1.py
> -rw-r--r-- 1 root root 3182 Dec 21 11:22 psycopg1.pyc
> -rw-r--r-- 1 root root 3167 Dec 12 13:49 psycopg1.pyo
> -rwxr-xr-x 1 root root 572648 Dec 21 11:22 _psycopg.so drwxr-xr-x 2 root root 4096 Dec 21 10:38 tests
> -rw-r--r-- 1 root root 4427 Dec 11 18:18 tz.py
> -rw-r--r-- 1 root root 4325 Dec 12 13:49 tz.pyc
> -rw-r--r-- 1 root root 4325 Dec 12 13:49 tz.pyo
But in python shell when I am trying to import library, I got error:
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib64/python2.4/site-packages/psycopg2/__init__.py", line 76, in ?
from psycopg2._psycopg import _connect, apilevel, threadsafety, paramstyle
ImportError: cannot import name _connect
I am running with Postgresql 9.2.
What am I missing here?
Please let me know.
Thanks.
You most likely have to remove some existing packages related to psycopg2 within your root. Some common locations:
rm -r /usr/lib/python2.4/site-packages/psycopg2*
rm -r /usr/local/lib/python2.6/dist-packages/psycopg2*
However, I recommend setting up a virtualenv to house the packages for your Python app.
Check out virtualenv. It's easy to use once installed:
virtualenv myapp
. myapp/bin/activate
cd ~/your/postgres_lib/download
python setup.py install
This will install postgres libraries into your virtualenv (located under the myapp) folder. Then, whenever you want to run your app, you just need to activate the environment via
. myapp/bin/activate
Adjusting the path to myapp when necessary. There are helpers, like virtualenvwrapper to streamline this process.