nohup cannot find file or directory when running script to start davmail

2

I am trying to set up davmail on text based Ubuntu to run in server mode and am following the instructions here, but when I try to run the line

nohup davmail.sh davmail.properties &

I get the message

nohup: failed to run command 'davmail.sh': No such file or directory

The davmail.sh script is as follows:

#!/bin/sh
# Ubuntu setup instructions :
# install java :
# sudo apt-get install default-jre
# launch davmail
BASE=`dirname $0`
for i in $BASE/lib/*; do export CLASSPATH=$CLASSPATH:$i; done
exec java -Xmx512M -Dsun.net.inetaddr.ttl=60 -cp $BASE/davmail.jar:$CLASSPATH davmail.DavGateway $1

I don't know which file(s) it is referring to when it says No such file or directory. It seems to me that everything should be there. I am wondering if I am missing some package or something, or if the script really is just trying to reference some file that isn't there. I am pretty new to Linux, so any help here would be greatly appreciated! Here is the tree of the directory the script resides in:

.
├── davmail-4.8.0-2479.zip
├── davmail.jar
├── davmail.log
├── davmail.properties
├── davmail.sh
├── lib
│   ├── activation-1.1.1.jar
│   ├── commons-codec-1.3.jar
│   ├── commons-collections-3.1.jar
│   ├── commons-httpclient-3.1.jar
│   ├── commons-logging-1.0.4.jar
│   ├── htmlcleaner-2.2.jar
│   ├── jackrabbit-webdav-2.4.3.jar
│   ├── jcharset-1.3.jar
│   ├── jcifs-1.3.14.jar
│   ├── jdom-1.0.jar
│   ├── log4j-1.2.16.jar
│   ├── mail-1.4.3.jar
│   ├── slf4j-api-1.3.1.jar
│   ├── slf4j-log4j12-1.3.1.jar
│   ├── stax2-api-3.1.1.jar
│   ├── stax-api-1.0.1.jar
│   ├── woodstox-core-asl-4.1.2.jar
│   └── xercesImpl-2.8.1.jar
└── nohup.out

Tom

Posted 2017-06-17T21:36:41.277

Reputation: 21

Answers

3

I can see from your tree listing that you are “in” the top-level directory of that tree (i.e., it is your current directory)1, and that davmail.sh is also in that top-level directory.  Do you have . (dot; i.e., the current directory) in your search path?  If you do, take it out, and keep on looking for an answer.

But if you don’t have . (dot; i.e., the current directory) in your search path (i.e., if you have a proper configuration), then you will need to do one of the following:

  • Type nohup ./davmail.sh davmail.properties &
  • Type nohup /full/path/to/current/directory/davmail.sh davmail.properties &, or
  • Put the current directory name (i.e., the name of the directory where davmail.sh is) into your search path,

… so nohup will know where to find davmail.sh.

__________
1  (I conclude that from the fact that nohup.out is there)

G-Man Says 'Reinstate Monica'

Posted 2017-06-17T21:36:41.277

Reputation: 6 509

1

I ran into the same problem. In my case, nohup was calling a script that was created in a windows machine. The script's line endings was CR LF instead of LF.

Running the script directly evidenced the error (example).

I just changed from Windows End-of-lines (CR LF) to Unix End-of-lines (LF) and it worked. Any decent text editor or IDE can do that for you.

Ric

Posted 2017-06-17T21:36:41.277

Reputation: 11