我使用的是 Process p = Runtime.getRuntime().exec(cmdArray);  这种方式来调用python文件
首先创建一个sh文件。sh文件执行py的命令,然后java调用sh文件1. 当我的tomcat启动方式  sh startup.sh  #这样执行WEB的时候。PY程序执行结果是对的。返回信息如下
[root@localhost ~]#  tail -f /opt/yosar/tomcat/logs/catalina.out 
tail: cannot open `/opt/yosar/tomcat/logs/catalina.out' for reading: No such file or directory
tail: no files remaining
[root@localhost ~]#  tail -f /opt/yostar/tomcat/logs/catalina.out 
Oct 18, 2009 5:03:34 AM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path  from URL file:/opt/yostar/tomcat/webapps/ROOT
Oct 18, 2009 5:03:34 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Oct 18, 2009 5:03:34 AM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
Oct 18, 2009 5:03:34 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/28  config=/opt/yostar/tomcat/conf/jk2.properties
Oct 18, 2009 5:03:34 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1692 ms
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
RealmLoginModule: login phase
user: 010001, role: Carrier Admin, enabled: Y.
RealmLoginModule: commit phase
RealmLoginModule: add role: [Carrier Admin], all has 2
RealmLoginModule: commit succesful
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
INFO - BaseBeanFactory.buildBeans(117) | Building beans complete: manager-config.xml
class:com.accessmedia.music.manager.impl.UserManagerImpl
DEBUG - HibernateSession.currentSession(52) | create hibernate session in current thread.
DEBUG - HibernateSession.closeSession(121) | close hibernate session in current thread.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
ImportsummaryAction -------------
class:com.accessmedia.music.manager.impl.ImportsummaryManagerImpl
DEBUG - HibernateSession.currentSession(52) | create hibernate session in current thread.
[]
DEBUG - HibernateSession.closeSession(121) | close hibernate session in current thread.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
m9.tar
sh /root/s3.sh
1.mp3-----------------------------------------
2. 当我的tomcat启动方式  service tomcatd start #这样执行WEB的时候。PY程序执行结果是错误的。返回信息如下[root@localhost ~]#  tail -f /opt/yostar/tomcat/logs/catalina.out 
Oct 18, 2009 5:06:46 AM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path  from URL file:/opt/yostar/tomcat/webapps/ROOT
Oct 18, 2009 5:06:46 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Oct 18, 2009 5:06:47 AM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
Oct 18, 2009 5:06:47 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/25  config=/opt/yostar/tomcat/conf/jk2.properties
Oct 18, 2009 5:06:47 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1620 ms
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
DEBUG - HibernateSession.closeSession(123) | try to close hiberante session in current thread, but can't find session.
RealmLoginModule: login phase
user: 010001, role: Carrier Admin, enabled: Y.
RealmLoginModule: commit phase
RealmLoginModule: add role: [Carrier Admin], all has 2
RealmLoginModule: commit succesful
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
INFO - BaseBeanFactory.buildBeans(117) | Building beans complete: manager-config.xml
class:com.accessmedia.music.manager.impl.UserManagerImpl
DEBUG - HibernateSession.currentSession(52) | create hibernate session in current thread.
DEBUG - HibernateSession.closeSession(121) | close hibernate session in current thread.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
ImportsummaryAction -------------
class:com.accessmedia.music.manager.impl.ImportsummaryManagerImpl
DEBUG - HibernateSession.currentSession(52) | create hibernate session in current thread.
[com.accessmedia.music.model.Importsummary@1d4ee7e]
DEBUG - HibernateSession.closeSession(121) | close hibernate session in current thread.
DEBUG - UserInfo.valueBound(146) | bound session [C4853E678F394D1FA0F833AFB17DAC39] -> [010001]
m10.tar
sh /root/s3.sh
1.mp3 
contents.txt--------------------------  carrierId = 1  ------------------------------------------------------------------------  spId = 1  ----------------------------------------------begin audio transcoding!madplay -o wave:temp.prelim.wav "/MDInestion/MDInestion/bin/working//AMS000024001_FT.mp3"sh: madplay: command not foundsox: Can't open input file 'temp.prelim.wav': No such file or directoryTraceback (most recent call last):  File "MDIngestion.py", line 1868, in ?    main()  File "MDIngestion.py", line 113, in main    audio_transcoding(tarball)  File "MDIngestion.py", line 529, in audio_transcoding    os.path.walk(os.getcwd()+"/working/", convert_audio, None)  File "/usr/lib/python2.4/posixpath.py", line 290, in walk    func(arg, top, names)  File "MDIngestion.py", line 228, in convert_audio    make_clip(30, 30, wav_dest, sample_dest)  File "/MDInestion/MDInestion/bin/MelUtil.py", line 48, in make_clip    wav = wave.open(infile)  File "/usr/lib/python2.4/wave.py", line 483, in open    return Wave_read(f)  File "/usr/lib/python2.4/wave.py", line 159, in __init__    f = __builtin__.open(f, 'rb')IOError: [Errno 2] No such file or directory: '/MDInestion/MDInestion/bin/working//AM/S00/00/24001/full.wav'ImportsummaryAction -------------
DEBUG - HibernateSession.currentSession(52) | create hibernate session in current thread.
[com.accessmedia.music.model.Importsummary@857066, com.accessmedia.music.model.Importsummary@966905]
DEBUG - HibernateSession.closeSession(121) | close hibernate session in current thread.