Jump to content

Ravendark

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by Ravendark

  1. Well it seems that I found what was wrong. I forced the php "exec" to use bash $uptime = exec("/bin/bash /var/www/html/slot_uptime/telnet_pots.sh $msan_ip $slot | grep load | awk -F \", load\" '{print \$1}' | awk -F \"up\" '{print \$2}'"); works ok now, thanks for all the help!
  2. Do you mean running the php command from the command line?
  3. Hello, I wrote a bash script that opens a telnet connection to a machine. Then again it opens another telnet connection within that machine (telnets to a card which has a local IP) and runs an uptime command. The script is: #!/bin/bash MSAN_IP=$1 SLOT_IP=$2 ARGS=2 if [ $# -ne $ARGS ]; then echo "`basename $0`: Wrong number or parameter supplied" echo "`basename $0`: Usage: `basename $0` <MSAN_IP> <SLOT_LOCAL_IP>" exit 0; else expect << EOF set timeout 5 spawn telnet $MSAN_IP 2323 expect "IPCP login: " send "root\r" expect "Password: " send "***\r" expect "~ # " send "telnet 10.1.3.$SLOT_IP\r" expect "60xADSL login: " send "root\r" expect "Password: " send "weblin1\r" expect "60xADSL# " send "uptime\r" expect "60xADSL# " send "exit\r" expect “~ # ” send "exit\r" exit EOF fi Now...I have a php webpage as an interface for this script. This is the code that calls the bash script: exec("/var/www/html/slot_uptime/telnet_pots.sh $msan_ip $slot > /var/www/html/slot_uptime/uptime_pots.txt"); $uptime = exec("cat /var/www/html/slot_uptime/uptime_pots.txt | grep load | awk -F \", load\" '{print \$1}'| awk -F \"up\" '{print \$2}'"); // | awk -F \", load\" '{print \$1}' if ($uptime == "") { echo "<h2>Could not retrieve uptime</h2><br>"; } The script works fine if I run it from the command line. It even works fine when the php script calls it. Though, there are 2 machines out of many that when the PHP script calls the bash script, the host closes the connection. Successful output: ./telnet_adsl.sh 10.193.0.3 4 spawn telnet 10.193.0.3 2323 Trying 10.193.0.3... Connected to 10.193.0.3. Escape character is '^]'. You are logging into Marconi IP Common Part "IPCP" IPCP login: root Password: ~ # telnet 10.1.3.4 Entering character mode Escape character is '^]'. Linux 2.4.20_mvl31-wds-mips_fp_be (60xADSL) (0) 60xADSL login: root Password: this is motd file to inform any information to user BusyBox v1.00-rc2 (2004.08.03-10:23+0000) Built-in shell (ash) Enter 'help' for a list of built-in commands. 60xADSL# uptime 06:58:28 up 15 days, 8:10, load average: 0.00, 0.00, 0.00 60xADSL# exit Connection closed by foreign host. Not successful: spawn telnet 10.193.0.5 2323 Trying 10.193.0.5... Connected to 10.193.0.5. Escape character is '^]'. Connection closed by foreign host. All the machines have the exactly the same software running on them (some sort or linux distro). Any ideas? Thanks in advance!
  4. Thanks for replying. The 2digit value is a port ifindex which is used to for shut-no shut. The rest is just the interface/port name which is also necessary for informing the user of which port is manipulating. I will just have to add a javacript test (if disabled alert the user) and I guess it will be fine. Thanks for your answers!
  5. Nah, won't help, cause I need the 2digit value as it is. I thought of a different way, I use javascript to place the text to a hidden text field, then pass it to php... Thanks though
  6. Hello, I am searching to find an answer to my question but without success. I have a HTML dropdown list like this: <select name="ports"> <option value="10">1/1/1/0/shdsl</option> <option value="12">1/1/2/0/shdsl</option> <option value="14">1/1/3/0/shdsl</option> <option value="16">1/1/4/0/shdsl</option> <option value="18">1/1/5/0/shdsl</option> <option value="20">1/1/6/0/shdsl</option> <option value="22">1/1/7/0/shdsl</option> <option value="24">1/1/8/0/shdsl</option> <option value="26">1/1/9/0/shdsl</option> <option value="28">1/1/10/0/shdsl</option> <option value="30">1/1/11/0/shdsl</option> <option value="32">1/1/12/0/shdsl</option> <option value="34">1/1/13/0/shdsl</option> <option value="36">1/1/14/0/shdsl</option> <option value="38">1/1/15/0/shdsl</option> <option value="40">1/1/16/0/shdsl</option> <option value="42">1/1/17/0/shdsl</option> <option value="44">1/1/18/0/shdsl</option> <option value="46">1/1/19/0/shdsl</option> <option value="48">1/1/20/0/shdsl</option> <option value="50">1/1/21/0/shdsl</option> <option value="52">1/1/22/0/shdsl</option> <option value="54">1/1/23/0/shdsl</option> <option value="56">1/1/24/0/shdsl</option> </select> All I want to do is to get the value & the text (e.g 56 & "1/1/24/0/shdsl"). I get the value (say 56) with: $_POST['ports'] Could you please help me get the text?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.