Python script called by a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Python script called by a shell script
# 1  
Old 03-17-2013
Python script called by a shell script

experts, i wrote a python script to do a certain job, i tried it and it is working fine, i want this script to be executed automatically after a ksh script, the problem is when i execute the ksh script my python script runes perfectly after the ksh script as I have include it at the end of the ksh script with the full path which is the same directory I am running the script from, but when a user run it from an oracle forms i got an error msg says
Code:
No such file or directory

I notice that the KSH script is executing a .profile file, i have include that too, i need an expert to tell me how can i execute my python inside the this ksh script.

this is the KSH script
Code:
#! /usr/bin/ksh
. $POWERCARD_HOME/.pcard_profile
#/pcard16/pwrcard/.pcard_profile

echo "================" >> $TRACE/card_production_batch.stat
echo "START PROCESSING" >> $TRACE/card_production_batch.stat
date_id=`date +%y%m%d%H%M`
echo $date_id >> $TRACE/card_production_batch.stat

card_production card_production $1 C 1>$TRACE/card_production_batch.stat  2>&1


export r=$?

## IOManager
#export TASK_NAME=card_production

#if [$proc_status -eq 1 ] 1>>/dev/null 2>&1
#then
#        STATUS=OK
#else
#        STATUS=KO
#fi
#export STATUS

#.iomanager1.sh
## IOManager
d=`date +%y%m%d%H%M`

echo $date_id >> $TRACE/card_production_batch.stat
echo "END   PROCESSING" >> $TRACE/card_production_batch.stat
echo "================" >> $TRACE/card_production_batch.stat

#echo $(date) >> /pcard16/pwrcard/usr/shl/mahdi_test

./embosingExtraction.py 2>>/pcard16/pwrcard/usr/shl/embose_debug.txt
#.$SHL/embosingExtraction.py 2>>/pcard16/pwrcard/usr/shl/embose_debug.txt
echo '---------------------------------------------' >>/pcard16/pwrcard/usr/shl/embose_debug.txt
#echo $(date) >> mahdi_test


exit $r

embosingExtraction.py is my python script i have placed it in the same directory of the KSH script. Here is a look at .pcard_profile that executed in the first line of the KSH script

Code:
#! /usr/bin/ksh
#######################################################
### Include Environnement Variables                  ##
#######################################################
export HOME=/pcard16/pwrcard
export POWERCARD_HOME=$HOME
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10g
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
export ORACLE_SID=pcard
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export ORACLE_LIB=$ORACLE_HOME/lib:/usr/lib:/lib
export TRACE=/pcard17/trace
export ARCHIVE=$HOME/usr/archive
export QUEUE=$HOME/usr/queue
export EXPORT=$HOME/usr/export
export BIN=$HOME/usr/bin
export SHL=$HOME/usr/shl
export CTL=$HOME/usr/ctl
export PATH=$PATH:$BIN:$SHL
export PATH=$PATH:$BIN:$SHL
export DATA=$HOME/usr/data
export DB_MODE=0
export DB_USER_PROD="xxxxxxxxxx"
export DB_USER_TEST="xxxxxxxxxx"
export DB_PASSWORD_PROD="xxxxxxxxxxxxxxxxxx"
export DB_PASSWORD_TEST="xxxxxxxxxxxxxxxxxx"
export EXP_USER=xxxxxxxx/xxxxxxxxx
#mahdi_addition:
export PATH=$PATH:/pcard16/pwrcard/usr/shl
export POWERCARD_TRACE=/pcard17/trace
#######################################################
export HOME_ENV_MAKEFILE=$HOME/src/libs
export PLATFORM="SOLARIS"
#export CC="fcc -KV9"
export LLIBSOCKETS=-lsocket
#######################################################
###  User compilation
#######################################################
export usercomp=xxxxxxxxxxx
export passwcomp=xxxxxxxxxx
export DEBUG_MODE="0"

# 2  
Old 03-26-2013
Executables, whether script or compiled, python or shell or whatever, all need execute permissions, scripts all need a $! first line and all should be accessed by $PATH not by definite paths, as described in man execvp(). Then, they are all peers and all run equally well, and the caller need not worry about what they were written in.

Python may want some environment setup that, if callers do not provide, you need to address. Having a simple shell test like if [ "$ZZPROFILED" =1 ] can tell you to run a profile and get things tuned up.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to pass values to a script called from within another script in shell?

Ceiling Light - The Forgotten Element One of the highest details concerning using an LED ceiling panel essentially offer a fantastic dance floor which definitely makes the customers dance right away.They are a quite low cost method of something like a lighting solution, simple collection up,... (1 Reply)
Discussion started by: harveyclayton
1 Replies

2. UNIX for Beginners Questions & Answers

How to pass values to a script called from within another script in shell?

Need ideas on how to achieve the below. We have a script say "profile.sh" which internally calls another existing script called "name.sh" which prompts for the name and age of a person upon execution. When i run profile.sh how can i populate a pre-defined value from another file and pass that... (1 Reply)
Discussion started by: sankasu
1 Replies

3. Shell Programming and Scripting

Shell script to pass the config file lines as variable on the respective called function on a script

I want to make a config file which contain all the paths. i want to read the config file line by line and pass as an argument on my below function. Replace all the path with reading config path line by line and pass in respective functions. how can i achieve that? Kindly guide. ... (6 Replies)
Discussion started by: sadique.manzar
6 Replies

4. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

5. Shell Programming and Scripting

How to monitor a shell script called within a script?

HIi Guys... I am in a fix.... 1st the code : Script 123.sh looks like this : ./abc # a script which is getting called in this script while true do count=`ps -ef | grep abc | wc -l` if echo "abc is running sleep 10 fi done but the process is getting checked... (5 Replies)
Discussion started by: chatwithsaurav
5 Replies

6. 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

7. UNIX for Dummies Questions & Answers

How to retrieve the value of variable in shell script which is called by crontab

There are two files one is shell script (sample.sh) and another is configuration file (sampl_conf.cfg) configuration file contains one variable $FTP_HOME. the value of this variable vaires for user to user. If user is say jadoo then value is /home/jadoo/ftp/, for user1 - /home/user1/ftp. The... (4 Replies)
Discussion started by: jadoo_c2
4 Replies

8. Shell Programming and Scripting

giving input to a python wch has been called frm shell script....urgent

i'm calling a python script from shell script. the python needs Y as an input everytime. how can i giv it thru shell script. I tried below code for arg in `cat erd_gen_list.lst` do generateErdSql.py -S $arg << Y done This is giving me err : `<<' unmatched pls help. (1 Reply)
Discussion started by: vini
1 Replies

9. Shell Programming and Scripting

How to return the value from the called shell script to the calling sh script

Hi all, I have two ksh scripts #sample1.sh #!/bin/ksh . ./sample2.sh echo $fileExist #sample2.sh #!/bin/ksh func() { i=1 return $a } func echo $? Here how should I return the value of sample2.sh back to sample1.sh? Thanks in advance. (2 Replies)
Discussion started by: gp_singh
2 Replies

10. 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
Login or Register to Ask a Question