Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
09-01-2004, 09:27 AM
|
#1
|
Member
Registered: Oct 2003
Location: London, UK
Distribution: Fedora Core 2
Posts: 41
Rep:
|
Help with shell script
Hello all, I have a problem with a script which came as part of a book example, the first line of the script after the #!/bin/sh line is simply this: SSH_DIR=/opt/ssh-dir, the directory exists and is readable by everyone, however when I run the script I receive this error: "SSH_DIR is a directory" the script then terminates, any ideas what this might be ??
regards
Pete Kane
|
|
|
09-01-2004, 09:32 AM
|
#2
|
Senior Member
Registered: Sep 2003
Location: Rio
Distribution: Debian
Posts: 1,513
Rep:
|
I'm not sure about it, but if you want to set it as an env. variable, you must do
export SSH_DIR=/opt/ssh-dir
instead.
|
|
|
09-02-2004, 04:19 AM
|
#3
|
Member
Registered: Oct 2003
Location: London, UK
Distribution: Fedora Core 2
Posts: 41
Original Poster
Rep:
|
sorry the error message is: "/opt/ssh-dir is a directory", if I run the script as root the error message is: "/root is a directory"
regards
Pete Kane
|
|
|
09-02-2004, 09:26 AM
|
#4
|
Senior Member
Registered: Jan 2004
Location: Montpellier (France)
Distribution: Gentoo
Posts: 1,014
Rep:
|
Hi,
Can you post more of your script? cause, it's probably when the script uses "$SSH_DIR" variable that the script fails.
Oliv'
|
|
|
09-03-2004, 04:42 AM
|
#5
|
Member
Registered: Oct 2003
Location: London, UK
Distribution: Fedora Core 2
Posts: 41
Original Poster
Rep:
|
here it is in its entirety, thanks for your time
#!/bin/sh
# Change me to the appropriate location of
# your SSH VPN installation directory
SSH_VPN_DIR=/opt/ssh-vpn
# No changes should be necessary from here down.
vpn_config () {
vpn_network=$1
# Grab global variables
. $SSH_VPN_DIR/etc/ssh-vpn.conf || exit 0
# Grab vpn-specific variables
VPN_CONFIG=$SSH_VPN_DIR/etc/$vpn_network
. $VPN_CONFIG || exit 0
if [ "$client_debug" = "yes" ] ; then
set -x
client_pppd_args="$client_pppd_args debug"
fi
}
run_as_sshvpn () {
whoami=`$WHOAMI`
pwd=`pwd`
case "$whoami" in
root) exec $SU - $SSH_VPN_USER "-ccd $pwd;$0 $*";
exit 0; ;;
$SSH_VPN_USER) ;;
*) echo "$0 Must be run as $SSH_VPN_USER" >&2;
exit 1; ;;
esac
}
# Determine how we should behave:
if [ ! -z "$LINKNAME" ] ; then
# We were called as the ip-up script from pppd
vpn_config $LINKNAME
# Configure our new route
# sudo not needed -- we were run from pppd as root
# $IPREMOTE is set by pppd for us
[ "$server_network" ] && $ROUTE add -net $server_network gw $IPREMOTE
exit 0;
elif [ "$1" = "stop" ] ; then
# We were invoked init.d style, as one of the following:
# /etc/init.d/vpn-client stop vpn1
# /etc/init.d/vpn1 stop
# /etc/rcX.d/S##vpnname stop
[ "$2" ] && vpn_config "$2" \
|| vpn_config `basename $0 | sed -e 's/^[SK][0-9][0-9]//'`
# Kill off the pppd and stunnel processes
kill `head -1 $PIDDIR/ppp-$vpn_network.pid` 2>/dev/null
exit 0;
elif [ "$1" = "start" ] ; then
# started init.d style, similar to above.
[ "$2" ] && vpn_config "$2" \
|| vpn_config `basename $0 | sed -e 's/^[SK][0-9][0-9]//'`
run_as_sshvpn "$@" # Make sure we're not root, etc.
# Fall through to actual startup stuff.
elif [ $# -eq 1 ] ; then
vpn_config $1
run_as_sshvpn "$@" # Make sure we're not root, etc.
# Fall through to actual startup stuff.
else
echo "Usage: $0 destination start|stop" >&2
echo "Usage: $0 start|stop" >&2
echo "Usage: (if $0 is a vpn name)" >&2
exit 1
fi
# Universal ssh arguments
# (yes, that's two '-t' entries here)
SSH_ARGS="-oBatchMode=yes -enone -t -t"
# Universal pppd arguments
PPPD_ARGS="updetach lock connect-delay 10000 name $vpn_network-client \
user $vpn_network-client linkname $vpn_network \
remotename $vpn_network-server $client_pppd_args pty"
# Munge PPPD_ARGS for desired auth level
if [ "$client_require_pap" = "yes" ] ; then
PPPD_ARGS="require-pap $PPPD_ARGS"
elif [ "$client_require_chap" = "yes" ] ; then
PPPD_ARGS="require-chap $PPPD_ARGS"
else
PPPD_ARGS="noauth $PPPD_ARGS"
fi
# Start our pppd/ssh processes
$SUDO $PPPD $PPPD_ARGS \
"$SUDO -u $SSH_VPN_USER $SSH $SSH_ARGS $client_ssh_args $vpn_network"
|
|
|
09-03-2004, 04:49 AM
|
#6
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,444
|
Well, there's no SSH_DIR var in that script.... why don't you try
set -xv
as the first line, which will show you exactly what it's doing.
|
|
|
09-03-2004, 07:10 AM
|
#7
|
Senior Member
Registered: Jan 2004
Location: Montpellier (France)
Distribution: Gentoo
Posts: 1,014
Rep:
|
Quote:
root) exec $SU - $SSH_VPN_USER "-ccd $pwd;$0 $*";
|
I think the error comes from this line. Try to insert before and after a line like: echo "before error" and echo "after error" to know if I'm right  If I'm right, we need to know more about ccd option to debug it
Oliv'
|
|
|
09-06-2004, 04:17 AM
|
#8
|
Member
Registered: Oct 2003
Location: London, UK
Distribution: Fedora Core 2
Posts: 41
Original Poster
Rep:
|
thanks to you both I'll give it a try when I'm back at my desk
regards
Pete Kane
|
|
|
09-08-2004, 06:12 AM
|
#9
|
Member
Registered: Oct 2003
Location: London, UK
Distribution: Fedora Core 2
Posts: 41
Original Poster
Rep:
|
Hello all, sorry for the delay in posting ( damn work !) the problem turned out to be blank lines at the end of the conf file, which is read on this line
# Grab global variables
. $SSH_VPN_DIR/etc/ssh-vpn.conf || exit 0
I have another problem now which is ppp authentication, but that's another story
regard and thanks for all your help
Pete Kane
|
|
|
All times are GMT -5. The time now is 06:28 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|