It would help if you show the script. How are you executing this? What is the command you send over to the server. Since you didn't supply the script I created x.sh that just outputs argument count, arguments...
echo $#
echo $*
exit
I didn't have problems with argument counting. This works....
Yes, "-c" is one argument and the rest is the second. Your problem is not the passing of the parameters but the splitting of them.
You could emulate the splitting along IFS characters inside your shell this way:
#! /bin/ksh
args="$1"
IFS=" "
while : ; do
print - "next: ${args%%${IFS}*}"
if [ "$args" != "${args#*${IFS}}" ] ; then
args="${args#*${IFS}}"
print - "rest: $args"
else
print - "rest:"
break
fi
done
When run it looks like this:
# ./split.ksh 'a b c def g h'
next: a
rest: b c def g h
next:
rest: b c def g h
next:
rest: b c def g h
next:
rest: b c def g h
next:
rest: b c def g h
next: b
rest: c def g h
next: c
rest: def g h
next: def
rest: g h
next: g
rest: h
next: h
rest:
Notice that you will have to throw out empty "args" in the loop to compensate for multiple consecutive IFS chars.
Its a simple script that take an IP and NAME_RECORD and update a dns file. Relaunches named after the change.
Thing is the user1 CANNOT have a valid login shell so the remote script acts as a login shell
usage () {
cat >&2 <<EOF
Insert/delete IP addresses and name records
in hosts DNS.
OS: RHEL 5.5
Usage: ${0##*/} -i \$IP_ADDRESS -n \$NAME_RECORD [ -D optional ]
- Default is to Insert
- D switch to Delete
EOF
Sorry for the confusion but i took the name x.sh from blackrageous to simplify the example. the real script name is insert_host_ip_named.bash
The script insert_host_ip_named.bash is mine but the webpage php code is not. I can give them what i want triggered but cannot modify the this flow:
User input info in php web page ----> that triggers from the http server the ssh to the named server which hosts the above script that modifies the dns files and relaunches named.
Exactly the opposite .... the php page will trigger the ssh to the remote server.
You put in the info on the php page (those become args for my script).
The php code will trigger the ssh with the args
ServerA (php code, user input) --- launches the ssh with args --- ServerB receive the ssh with args and trigger upon login my above script with the correct args.
Ohhhhhh f... me .... i'll take a look again tomorrow morning Not sure if i'll be able to make it work the first time but i'll do my best
Thanks alot for your help. I'll keep ya posted.
---------- Post updated 04-01-14 at 12:11 PM ---------- Previous update was 03-31-14 at 09:24 PM ----------
Ok round 2
I've looked at your method and mine just want to be sure about the work flow cause i'm still confused.
My method. Or at least what was the original plan:
User gets to a web page with a form asking for information (ip, host, remove or not).
He put's all the required info and push send.
The php code opens up a remote ssh connection (with remote server ip address of server plus credentials).
That login trigger the login shell which is my bash script. That runs with the desire arguments that comes from the ssh args.
That is the way i see it.
In my head your method goes like this.
PHP web page trigger the ssh connection which opens up the login shell script on the remote server and asks for information. Script is now open so it takes stdin info that the user provides and uses them to run the script.
Is that correct or am i far left field in lalaland?