473,385 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Simultanous processes in shell script

13
Dear all,

I am trying to write a shell script that creates a ssh tunnel to a remote server and checks out a module from a CVS repository. The problem is that the tunnel creation blocks the terminal. That means I have to wait for a moment till the tunnel is established and than apply the CVS commands on a different terminal. How can this be done with a shell script such that the process can be automatic? I already tried to put an ampersand after the ssh line, but then the connection is aborted at the time the CVS commands are entered. Thanks in advance.

Siebbel

This is what I tried:
Expand|Select|Wrap|Line Numbers
  1. ssh -L 2401:localhost:2401 user@somewhere.com &
  2. sleep 10
  3. export CVSROOT=:pserver:cvs@localhost:/data/cvs
  4. cvs update -d module &
  5.  
Apr 3 '07 #1
4 2762
Motoma
3,237 Expert 2GB
Take a look at this short guide on SSH Tunneling.
Google SSH Tunneling if you need more help.
Apr 3 '07 #2
Siebbel
13
I googled a lot already but al methods offered did not work. I can fork the tunnel to the background for an amount of time using the command sleep, but then the connection is immediately closed:

Expand|Select|Wrap|Line Numbers
  1. ssh -fv -L 2401:localhost:2401 cvs@colab.capitaltoolcompany.com sleep 25
  2. <enter>
  3. debug1: Authentication succeeded (publickey).
  4. debug1: Connections to local port 2401 forwarded to remote address localhost:2401
  5. debug1: Local forwarding listening on 127.0.0.1 port 2401.
  6. debug1: channel 0: new [port listener]
  7. debug1: Local forwarding listening on ::1 port 2401.
  8. debug1: channel 1: new [port listener]
  9. debug1: channel 2: new [client-session]
  10. debug1: Entering interactive session.
  11. [root@neptune html]# debug1: Sending command: sleep 25
  12. Press Enter to close this session...
  13. debug1: client_input_channel_req: channel 2 rtype exit-status reply 0
  14. debug1: channel 2: free: client-session, nchannels 3
  15. debug1: channel 0: free: port listener, nchannels 2
  16. debug1: channel 1: free: port listener, nchannels 1
  17. debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.1 seconds
  18. debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
  19. debug1: Exit status 0
  20.  
Here I gave only the final part of the output, since the first part is what one expects when the tunnel is set up. After this output, no connection is available anymore, <enter> terurnes to prompt. I've looked at dozens of pages concerning ssh tunneling but no usefull comments till now. Can anybody help me?

Siebbel
Apr 3 '07 #3
Motoma
3,237 Expert 2GB
It appears your source port and destination port are the same port on the same machine...Is that what you are trying to do?
Apr 3 '07 #4
Siebbel
13
This is also something I got from a ssh tutorial. And it works fine from the command line: when I enter
Expand|Select|Wrap|Line Numbers
  1. ssh –v –a –L 2401:localhost:2401 user@remoteserver
  2.  
an ssh tunnel is opened and through a different terminal I am able to send the commands I want to, or scp or whatever. The problem lies in the fact that I have to do that in a different terminal and a shell script is run from one. Using the -f option from the command line doesn't work (see output above), although this is how it is described in the literature.

Siebbel
Apr 3 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Bob Swerdlow | last post by:
My application starts up a number of processes for various purposes using: self.popen = popen2.Popen3("/usr/local/bin/python -O "myscript.py") and then shuts them down when appropriate with...
1
by: Jelle Feringa // EZCT / Paris | last post by:
James, Terry, Thanks for your constructive comments. Let's see if we can come down to the heart of the matter, it seems to me these are fundamental issues relevant in any shell script. I'm...
2
by: John Abel | last post by:
Hi! I'm currently writing a script which launches external programs, but it keeps leaving zombie/defunct processes behind, until I kill the launching script, which is a bit of a pain, as it's...
2
by: Joe Lester | last post by:
I'm trying to run PostgreSQL 7.4.1 on Mac OS 10.2.6. I'm running into problems when the number of process for the postgres user reaches 100. When that happens I get a "No More Processes" message in...
2
by: schreckmail | last post by:
Hi all! I'm launching a subprocess using the following code, and I'd like to kill off all associated subprocesses after a given timeout: myproc = popen2.Popen3(command) Now, because the...
8
by: mandydhaliwal | last post by:
Hi all, I am porting a win32 c++ program on Linux which first reads a list of processes and their paths from a file.Then this program should launch all of thesese processes. I tried to...
10
by: Michel Leunen | last post by:
Hi, I'm trying to write a python script for Nautilus. To get the list of files selected in the Nautilus right pane, you use the $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS environment variable which is...
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
1
by: replysonika | last post by:
Hello, I run a Java app with subprocess from Python script. This python script is called from another Python Wrapper. python = subprocess.Popen(, stdout=subprocess.PIPE,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.