LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-08-2011, 12:31 AM   #1
wch705
LQ Newbie
 
Registered: Jul 2010
Location: Australia
Distribution: Debian
Posts: 23

Rep: Reputation: 0
how to run .sh directly without cd to the parent directory?


hi all,
I know if i want to run a a.sh file under tmp, that is (/tmp/a.sh), i enter
Code:
$: cd /tmp
$: ./a.sh
but how can i run it without cd to tmp folder like
Quote:
$:./tmp/a.sh
apparently, the above code is not working at all?
thanks for helping
 
Old 11-08-2011, 12:40 AM   #2
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 193Reputation: 193
Its not working because you left the dot in there.

"." means current directory.

Code:
/tmp/a.sh
assuming the file is chmod +x
 
1 members found this post helpful.
Old 11-08-2011, 01:17 AM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
files in the temporary folder should NOT be able to be executed

the tmp is a kind of cesspool, you really do not want to execute files that are dropped in there .
By default that folder should not allow a normal user to execute files and run a script from there .
 
Old 11-08-2011, 01:24 AM   #4
wch705
LQ Newbie
 
Registered: Jul 2010
Location: Australia
Distribution: Debian
Posts: 23

Original Poster
Rep: Reputation: 0
thanks for answering.
the /tmp/a.sh is just an example and sorry for making such a bad example.
 
Old 11-08-2011, 01:29 AM   #5
wch705
LQ Newbie
 
Registered: Jul 2010
Location: Australia
Distribution: Debian
Posts: 23

Original Poster
Rep: Reputation: 0
actually i am trying to run the following
Code:
~$ ~/ofbiz/startofbiz.sh 
Unable to access jarfile ofbiz.jar
ofbiz is an ERP partly written by java
, what is happening?

If i cd to /ofbiz, and run ./startofbiz.sh it works.
 
Old 11-08-2011, 01:39 AM   #6
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 193Reputation: 193
you need to specify the full path for the *.jar file as well from with in the script, I imagine.
 
Old 11-08-2011, 01:41 AM   #7
linuxwin2
Member
 
Registered: Oct 2011
Posts: 44

Rep: Reputation: Disabled
Can you cat the content of startofbiz.sh
You can modify it.
 
Old 11-08-2011, 02:13 AM   #8
wch705
LQ Newbie
 
Registered: Jul 2010
Location: Australia
Distribution: Debian
Posts: 23

Original Poster
Rep: Reputation: 0
Code:
#!/bin/sh
#####################################################################
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#####################################################################

# shutdown settings
ADMIN_PORT=10523
ADMIN_KEY=so3du5kasd5dn

# console log file
OFBIZ_LOG=runtime/logs/console.log

# delete the last log
rm -f $OFBIZ_LOG

# VM args
ADMIN="-Dofbiz.admin.port=$ADMIN_PORT -Dofbiz.admin.key=$ADMIN_KEY"
#DEBUG="-Dsun.rmi.server.exceptionTrace=true"
#DEBUG="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8091"
#automatic IP address for linux
#IPADDR=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
#RMIIF="-Djava.rmi.server.hostname=$IPADDR"
MEMIF="-Xms128M -Xmx512M -XX:MaxPermSize=512m"
#JMX="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=33333 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
#MISC="-Duser.language=en"
VMARGS="$MEMIF $MISC $JMX $DEBUG $RMIIF $ADMIN"

# Worldpay Config
#VMARGS="-Xbootclasspath/p:applications/accounting/lib/cryptix.jar $VMARGS"

# location of java executable
if [ -f "$JAVA_HOME/bin/java" ]; then
  JAVA="$JAVA_HOME/bin/java"
else
  JAVA=java
fi

# Allows to run from Jenkins. See http://wiki.jenkins-ci.org/display/JENKINS/ProcessTreeKiller. Cons: the calling Jenkins job does not terminate if the log is not enabled, pros: this allows to monitor the log in Jenkins
#BUILD_ID=dontKillMe

# start ofbiz
#$JAVA $VMARGS -jar ofbiz.jar $* >>$OFBIZ_LOG 2>>$OFBIZ_LOG&
exec "$JAVA" $VMARGS -jar ofbiz.jar "$@"
Here is the cat session, what should i do next?
thanks
 
Old 11-08-2011, 02:19 AM   #9
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
Quote:
# start ofbiz
#$JAVA $VMARGS -jar ofbiz.jar $* >>$OFBIZ_LOG 2>>$OFBIZ_LOG&
exec "$JAVA" $VMARGS -jar ofbiz.jar "$@"
you will need to add the full path to "ofbiz.jar"
it looks like it will be in /var/log

but that this script will also need to also be /var/log
 
Old 11-08-2011, 02:20 AM   #10
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 193Reputation: 193
Quote:
Originally Posted by wch705 View Post
exec "$JAVA" $VMARGS -jar ofbiz.jar "$@"
Change any paths to use full paths, rather than relative.
Or use a variable to contain the path, for more portability.

Code:
exec "$JAVA" $VMARGS -jar ~/ofbiz/ofbiz.jar "$@"
(assuming that is where ofbiz.jar is located of course)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a directory named like his Parent Directory sina_saeedi82 Linux - Newbie 8 05-26-2011 11:36 AM
Squid: files larger than 50 MB to parent proxy, others directly dzany Linux - Server 0 12-08-2010 06:17 AM
Run script on every file contained within a parent directory and its subdirectories General Programming 4 05-15-2006 02:12 AM
List only the parent directory scottrell Linux - General 6 11-07-2003 09:10 AM
mv the contents of one directory to the parent directory warkrime Linux - Newbie 4 07-14-2003 07:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration