![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| function returns string | lalelle | Shell Programming and Scripting | 5 | 08-23-2007 06:16 PM |
| first value of array returns blank | Sudhakar333 | Shell Programming and Scripting | 1 | 08-06-2007 10:16 AM |
| vmstat returns good val for cpuIdle put ps shows no active process | OFFSIHR | Shell Programming and Scripting | 5 | 04-09-2007 02:01 PM |
| longjmp never returns | axes | High Level Programming | 2 | 09-10-2006 09:22 PM |
| inet_addr() returns 0 | soulfactory2002 | High Level Programming | 1 | 06-02-2005 05:25 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
process grepping returns itself
I am trying to write a script to make a ssh tunnel persist. I am writing it to check the existence of the tunnel on port 3307 and if it is not found start it:
#!/usr/local/bin/bash # ~/my_tunnel.sh tunnel_up=`ps ax|grep 3307` if [ "${tunnel_up}" = "" ]; then ssh -fNg -C -L 3307:127.0.0.1:3306 bob@db.webstakez.com & 2>/dev/null fi I believe that this is not working because the grep is returning a value for the actual grep command even when the tunnel is down. As an example, I check for anything on port 3308 since the tunnel is up: $ ps waux|grep 3308 10014 18755 0.0 0.0 1428 440 pts/0 S 12:53 0:00 grep 3308 This is a Linux system, 2.4.20-021stab028.3.777-enterprise #1 and grep does not act this way on my freebsd box. What can I do to so that this will not return the actual grep? TIA, Bob |
|
||||
|
my tunnel
I am trying to get something similar established. The following code is ~/bin/mytunnel.sh Code:
#!/bin/sh
# ~/bin/my_tunnel.sh
tunnel_up=`ps ax|grep 1080 | grep -v 'grep'`
if [ "${tunnel_up}" = "" ]; then
ssh -D 127.0.0.1:1080 andyhase@tripleyou.dyndns.org & &0 < 'password'
fi
I would like to have the script insert the password via stdin when the password question of ssh comes up. As of right now I get the error message: Code:
5: Syntax error: "&" unexpected Thanks, Andreas |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|