Sponsored Content
Top Forums Shell Programming and Scripting Script not working when called by cron Post 302288938 by cooldude on Wednesday 18th of February 2009 10:20:30 AM
Old 02-18-2009
This works:
Code:
#!/apps/python/2.3.4/bin/python

import os
import sys
import time

user = os.getenv("LOGNAME").replace("LOGNAME=", "")
string = time.strftime("%m%d%y0000 " + user, time.gmtime())

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

gzip in shell script called by cron

I'm puzzled by this one. I hope you can explain it to me. I have a ksh shell script that gzips a file among other things. This works perfectly fine when the script is manually run through a shell. However, when the same script is run through cron, it does everything correctly, but it will... (2 Replies)
Discussion started by: hbau419
2 Replies

2. Shell Programming and Scripting

How to determine the script is called from CRON?

Hello expert, What I want is to determine whether the script is called from CRON or it is executed interactively? I tried the following but no luck: #!/bin/ksh cronID=`pgrep -x cron` GPID=`ps -ef -o ppid,pid | grep " $PPID$" | awk '{print $1}'` if ; then echo I am being run... (15 Replies)
Discussion started by: wes_brooks
15 Replies

3. Shell Programming and Scripting

How to determine if a script (perl) was called from a CRON job or commandline

Hi, Is there a way to determine if a Script is called from a CRON job or from a commandline Gerry. (2 Replies)
Discussion started by: jerryMcguire
2 Replies

4. Shell Programming and Scripting

script not working in CRON

guys i have written a very simple script .it runs manually well. but when i put it in cron,it doesn't give the desired output. script looks like this: #! /usr/bin/sh #script for loading data in table using ctl file/Abhijeet K/08.07.2006 /svm_wl1/. .profile cd... (5 Replies)
Discussion started by: abhijeetkul
5 Replies

5. Shell Programming and Scripting

Shell script not working in cron

Hello, I know little about shell scripting and creating a script, and worked fine in the command line. But not work in the cron. Below you could see the script #!/bin/sh LOGFILE=/home/transfield/mou/test.log # Find yesterday Date and copy files TODAY=$(date --date= +%F) YESTERDAY=$(date... (4 Replies)
Discussion started by: malikp
4 Replies

6. Shell Programming and Scripting

Script is not working from cron while working manually

Hello, I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me 1) How could I check my script when it is running from cron like... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

7. UNIX for Dummies Questions & Answers

Interpreting Shell Script errors when called from CRON

Hi All, I am calling a series of shell scripts via CRON so everything is running as root. However, in my error log file I am seeing the following errors. Please can anyone offer any advise as to the possible causes and solution to prevent the errors from appearing. The Error 1227 seems to... (2 Replies)
Discussion started by: daveu7
2 Replies

8. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

9. Shell Programming and Scripting

Shell script not getting called through cron job but executes fine manually.

Hi, My shell script not getting called through cron job. The same works fine when executed manually. I tried to generate logs to find if the scripts has some errors related to path using following command- trying to execute .sh file every 5 mins: */5 * * * * /home/myfolder/abc.sh... (17 Replies)
Discussion started by: Dejavu20
17 Replies

10. Shell Programming and Scripting

Calling bash script works when called manually but not via Cron?

Hi, I've got a Bash backup script I'm trying to run on a directory via a cron job nightly. If I ssh in and run the script manually it works flawlessly. If I set up the cron to run evertything is totally messed up I don't even know where to begin. Basically the path structure is ... (6 Replies)
Discussion started by: wyclef
6 Replies
dpm2_python(3)							 Python Reference						    dpm2_python(3)

NAME
dpm - Python interface to the DPM SYNOPSIS
import dpm2 as dpm DESCRIPTION
The dpm module permits you to access the DPM client interface from python programs. The dpm module is a swig wrapping of the standard C interface. For detailed descriptions of each function see the individual man page of each function. FUNCTIONS
dpns_aborttrans ( ) dpns_access ( string path, int amode ) -> bool access dpns_accessr ( string sfn, int amode ) -> bool access dpns_addreplica ( string guid, struct dpns_fileid *file_uniqueid, string server, string sfn, char status, char f_type, string poolname, string fs ) dpns_addreplicax ( string guid, struct dpns_fileid *file_uniqueid, string server, string sfn, char status, char f_type, string poolname, string fs, char r_type, string setname ) dpns_chdir ( string path ) dpns_chmod ( string path, mode_t mode ) dpns_chown ( string path, uid_t new_uid, gid_t new_gid ) dpns_client_setAuthorizationId ( uid_t uid, gid_t gid, string mech, string id ) dpns_client_setVOMS_data ( string voname, stringlist vomsdata ) dpns_closedir ( dpns_DIR dirp ) dpns_creat ( string path, mode_t mode ) dpns_delcomment ( string path ) dpns_delete ( string path ) dpns_delreplica ( string guid, struct dpns_fileid *file_uniqueid, string sfn ) dpns_delreplicasbysfn ( ListOfString sfns, ListOfString guids ) -> ListOfInt results dpns_endsess ( ) dpns_endtrans ( ) dpns_getacl ( string path, ) -> ListOf struct dpns_acl acls dpns_getcomment ( string path ) -> string comment dpns_getcwd ( ) -> string dir dpns_getifcevers ( ) -> string version dpns_getlinks ( string path, string guid ) -> ListOf struct dpns_linkinfo links dpns_getreplica ( string path, string guid, string se ) -> ListOf struct dpns_filereplica replicas dpns_getreplicax ( string path, string guid, string se ) -> ListOf struct dpns_filereplicax replicas dpns_lchown ( string path, uid_t new_uid, gid_t new_gid ) dpns_listreplicax ( string poolname, string server, string fs, int flags, dpns_list * listp ) -> struct dpns_filereplica replica dpns_listrepset ( string setname, int flags, dpns_list *listp ) -> struct dpns_filereplicax replica dpns_lstat ( string path ) -> struct dpns_filestat statbuf dpns_mkdir ( string path, mode_t mode ) dpns_modreplica ( string sfn, string setname, string poolname, string server ) dpns_modreplicax ( string sfn, string setname, string poolname, string server, string fs, char r_type ) dpns_opendir ( string path ) -> dpns_DIR dir dpns_opendirxg ( string server, string path, string guid ) -> dpns_DIR dir dpns_ping ( string server ) -> string info dpns_readdir ( dpns_DIR dirp ) -> struct dirent dirent dpns_readdirc ( dpns_DIR dirp ) -> struct dpns_direncomm dirent dpns_readdirg ( dpns_DIR dirp ) -> struct dpns_direnstatg dirent dpns_readdirx ( dpns_DIR dirp ) -> struct dpns_direnstat dirent dpns_readdirxc ( dpns_DIR dirp ) -> struct dpns_direnstatc dirent dpns_readdirxp ( dpns_DIR dirp, string pattern, string se = None ) -> struct dpns_direnrep dirent dpns_readdirxr ( dpns_DIR dirp, string se = None ) -> struct dpns_direnrep dirent dpns_readlink ( string path ) -> string link dpns_rename ( string oldpath, string newpath ) dpns_rewinddir ( dpns_DIR dirp ) dpns_rmdir ( string path ) dpns_setacl ( string path, ListOf struct dpns_acl acls ) dpns_setatime ( string path, struct dpns_fileid file_uniqueid ) dpns_setcomment ( string path, string comment ) dpns_setfsize ( string path, struct dpns_fileid file_uniqueid, long filesize ) dpns_setfsizec ( string path, struct dpns_fileid file_uniqueid, long filesize, string csumtype, string csumvalue ) dpns_setptime ( string sfn, long ptime ) dpns_setratime ( string sfn ) dpns_setrltime ( string sfn, long ltime ) dpns_setrstatus ( string sfn, char status ) dpns_setrtype ( string sfn, char type ) dpns_startsess ( string server, string comment ) dpns_starttrans ( string server, string comment ) dpns_stat ( string path ) -> struct dpns_filestat statbuf dpns_statg ( string path, string guid ) -> struct dpns_filestatg statbuf dpns_statr ( string sfn) ) -> struct dpns_filestatg statbuf dpns_symlink ( string target, string linkname ) dpns_umask ( mode_t cmask ) -> mode_t oldmask dpns_undelete ( string path ) dpns_unlink ( string path ) dpns_utime ( string path, struct utimbuf times ) dpns_entergrpmap ( gid_t gid, string groupname ) dpns_enterusrmap ( uid_t uid, string username ) dpns_getgrpbygid ( gid_t gid ) -> string group dpns_getgrpbygids ( ListOfgid_t gids ) -> ListOfString groups dpns_getgrpbynam ( string groupname ) -> gid_t gid dpns_getgrpmap ( ) -> ListOf struct dpns_groupinfo infos dpns_getusrbynam ( string username ) -> uid_t uid dpns_getusrbyuid ( uid_t uid ) -> string user dpns_getusrmap ( ) -> ListOf struct dpns_userinfo userinfo dpns_modifygrpmap ( gid_t gid, string newname ) dpns_modifyusrmap ( uid_t uid, string newname ) dpns_rmgrpmap ( gid_t gid, string groupname ) dpns_rmusrmap ( uid_t uid, string username ) dpm_getpoolfs ( string poolname ) -> ListOf struct dpm_fs dpm_fs dpm_getpools ( ) -> ListOf struct dpm_pool dpm_pools dpm_getprotocols ( ) -> ListOfString protocols dpm_getspacemd ( ListOfString s_tokens ) -> ListOf struct dpm_space_metadata spacemd dpm_getspacetoken ( string u_token ) -> ListOfString s_tokens dpm_addfs ( string poolname, string server, string fs, int status ) dpm_addpool ( struct dpm_pool dpm_pool ) dpm_delreplica ( string pfn ) dpm_modifyfs ( string server, string fs, int status ) dpm_modifypool ( struct dpm_pool dpm_pool ) dpm_ping ( string host ) -> string info dpm_releasespace ( string s_token, int force ) dpm_reservespace ( char s_type, string u_token, char ret_policy, char ac_latency, long req_t_space, long req_g_space, long req_lifetime, ListOfInt gids, string poolname ) -> char actual_s_type, long actual_t_space, long actual_g_space, long actual_lifetime, string s_token dpm_rmfs ( string server, string fs ) dpm_rmpool ( string poolname ) dpm_updatespace ( string s_token, long req_t_space, long req_g_space, long req_lifetime, ListOfInt gids ) -> long actual_t_space, long actual_g_space, long actual_lifetime STRUCTURES
Sometimes you need to specify a structure as an input argument (eg. struct dpns_acl, struct dpns_list, struct dpm_pool, etc.). For that purpose, the module includes structure constructors, named exactly as the structure. Thus, to create struct dpns_acl, struct dpns_list or struct dpmm_pool, you have to do the following: dpnsacl = dpm.dpns_acl() dpnslist = dpm.dpns_list() dpmpool = dpm.dpm_pool() If you want to see how to use it in a real case, please have a look at examples. ERRORS
As you can see, no error code is returned. When an error occurs, an exception is raised with a description of the error. EXAMPLE
#!/usr/bin/python """ # Using the dpns_readdirxr method """ import sys import traceback import dpm2 as dpm name = "/dpm/cern.ch/home/dteam/"; try: dir = dpm.dpns_opendir(name) while 1: entry = dpm.dpns_readdirxr(dir) if entry == None: break print entry.d_name for i in range(entry.nbreplicas): print " ==> %s" % entry.rep[i].sfn dpm.dpns_closedir(dir) except TypeError, x: print " ==> None" except Exception: traceback.print_exc() sys.exit(1) EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpns_getreplica method """ file = "/dpm/cern.ch/home/dteam/file.test" try: list = dpm.dpns_getreplica(file, "", "") except Exception: traceback.print_exc() sys.exit(1) for i in list: print i.host print i.sfn EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpns_getacl and dpns_setacl methods to add a user ACL """ file = "/dpm/cern.ch/home/dteam/file.test" try: acls_list = dpm.dpns_getacl(file) except Exception: traceback.print_exc() sys.exit(1) for i in acls_list: print i.a_type print i.a_id print i.a_perm # When adding a first ACL for a given user, you also need to add the mask # When adding the second user ACL, it is not necessary anymore acl_user = dpm.dpns_acl() acl_mask = dpm.dpns_acl() acl_user.a_type = lfc.CNS_ACL_USER acl_user.a_id = 18701 # user id acl_user.a_perm = 5 acl_mask.a_type = lfc.CNS_ACL_MASK acl_mask.a_id = 0 # no user id specified acl_mask.a_perm = 5 acls_list.append(acl_user) acls_list.append(acl_mask) try: dpm.dpns_setacl(file, acls_list) except Exception: traceback.print_exc() sys.exit(1) EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpns_getacl and dpns_setacl methods to remove a user ACL """ file = "/dpm/cern.ch/home/dteam/file.test" try: acls_list = dpm.dpns_getacl(file) except Exception: traceback.print_exc() sys.exit(1) for i in acls_list: print i.a_type print i.a_id print i.a_perm del acls_list[1] # delete a given user ACL from the list of ACLs try: dpm.dpns_setacl(file, acls_list) except Exception: traceback.print_exc() sys.exit(1) EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpns_getusrmap method """ try: list = dpm.dpns_getusrmap() except Exception: traceback.print_exc() sys.exit(1) for i in list: print i.userid + " " + i.username EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpns_getgrpmap method """ try: list = dpm.dpns_getgrpmap() except Exception: traceback.print_exc() sys.exit(1) for i in list: print i.gid + " " + i.groupname EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_addfs method """ try: dpm.dpm_addfs("mypool", "mydiskserver.domain.com", "/mountpoint", dpm.FS_READONLY) except Exception: traceback.print_exc() sys.exit(1) EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_modifyfs method """ try: dpm.dpm_modifyfs("mydiskserver.domain.com", "/mountpoint", dpm.FS_READONLY) except Exception: traceback.print_exc() sys.exit(1) EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_rmfs method """ try: dpm.dpm_rmfs("mypool", "mydiskserver.domain.com", "/mountpoint") except Exception: traceback.print_exc() sys.exit(1) EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_addpool method """ dpmpool = dpm.dpm_pool() dpmpool.poolname = "mypool" dpmpool.defsize = 209715200 dpmpool.def_lifetime = 604800 dpmpool.defpintime = 604800 dpmpool.max_lifetime = 604800 dpmpool.max_pintime = 604800 dpmpool.nbgids = 1 dpmpool.gids = [0] dpmpool.ret_policy = 'R' dpmpool.s_type = 'D' try: dpm.dpm_addpool(dpmpool) except Exception: traceback.print_exc() sys.exit(1) EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_modifypool method """ dpmpool = dpm.dpm_pool() dpmpool.poolname = "mypool" dpmpool.defsize = 209715200 dpmpool.def_lifetime = 604800 dpmpool.defpintime = 604800 dpmpool.max_lifetime = 604800 dpmpool.max_pintime = 604800 dpmpool.nbgids = 1 dpmpool.gids = [0] dpmpool.ret_policy = 'R' dpmpool.s_type = 'D' try: dpm.dpm_modifypool(dpmpool) except Exception: traceback.print_exc() sys.exit(1) EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_rmpool method """ try: dpm.dpm_rmpool("mypool") except Exception: traceback.print_exc() sys.exit(1) EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_getpoolfs method """ try: list = dpm.dpm_getpoolfs("mypool") except Exception: traceback.print_exc() sys.exit(1) print len(list) for i in list: print "POOL " + i.poolname + " SERVER " + i.server + " FS " + i.fs + " CAPACITY " + i.capacity + " FREE " + i.free EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_getpools method """ try: list = dpm.dpm_getpools() except Exception: traceback.print_exc() sys.exit(1) print len(list) for i in list: print "POOL " + i.poolname + " CAPACITY " + i.capacity + " FREE " + i.free EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_getprotocols method """ try: list = dpm.dpm_getprotocols() except Exception: traceback.print_exc() sys.exit(1) print len(list) for i in list: print i EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_getspacemd method """ try: list = dpm.dpm_getspacemd(["myspacetoken"]) except Exception: traceback.print_exc() sys.exit(1) print len(list) for i in list: print "TYPE " + i.s_type + " SPACETOKEN " i.s_token + " USERTOKEN " + i.u_token + " TOTAL " + i.t_space + " GUARANTUEED " + i.g_space + " UNUSED " + i.u_space + " POOL " + i.poolname EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_getspacetoken method """ try: list = dpm.dpm_getspacetoken("myspacetokendesc") except Exception: traceback.print_exc() sys.exit(1) print len(list) for i in list: print i EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_reservespace method """ try: actual_s_type,actual_t_space,actual_g_space,actual_lifetime,s_token = dpm.dpm_reservespace('D', "myspacetokendesc", 'R', 'O', 209715200, 209715200, 2592000, 0, "mypoolname") except Exception: traceback.print_exc() sys.exit(1) print "TYPE " + actual_s_type + " TOTAL " + actual_t_space + " GUARANTEED " + actual_g_space + " LIFETIME " + actual_lifetime + " TOKEN " + s_token EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_updatespace method """ try: actual_t_space,actual_g_space,actual_lifetime = dpm.dpm_updatespace("myspacetoken", 209715200, 209715200, 2592000) except Exception: traceback.print_exc() sys.exit(1) print " TOTAL " + actual_t_space + " GUARANTEED " + actual_g_space + " LIFETIME " + actual_lifetime EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_releasespace method """ try: dpm.dpm_releasespace("myspacetoken", 0) except Exception: traceback.print_exc() sys.exit(1) EXAMPLE
#!/usr/bin/python import sys import traceback import dpm2 as dpm """ # Using the dpm_ping method """ try: info = dpm.dpm_ping("mydpmserver.domain.com") except Exception: traceback.print_exc() sys.exit(1) print info SEE ALSO
DPM C interface man pages DPM
$Date: 2010-12-14 08:31:05 +0100 (Tue, 14 Dec 2010) $ dpm2_python(3)
All times are GMT -4. The time now is 03:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy