Sponsored Content
Top Forums Shell Programming and Scripting ssh, cd to a dir, and and then do some work. Post 302071186 by tphyahoo on Thursday 13th of April 2006 06:03:04 AM
Old 04-13-2006
ssh, cd to a dir, and and then do some work.

I want to do something like

#!/bin/bash
ssh name@computer 'cd /my/dir'

and then continue working in this directory.

Right now if I execute a script "myscript" containing the above, it just drops me back into the bash shell where I started, whereas I want to be able to do work and stuff on this other computer.

I know this command is being execututed because if I change the script to

#!/bin/bash
ssh name@computer 'echo blah > blah.txt'

blah.txt does get created on the remote computer.

So the main question is, how do I keep that remote session open rather than reverting back to my original session.

I tried

./myscript &

but that didn't work.

Obviously this is a pretty simple problem, but I figure if I can get this working I learn something that can be applied to solving more powerful scenarios.

Thanks for your help in advance!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How does /export dir work?

In solaris I can switch to /export/appl/home or /appl/home to get to my home dir. If I switch to /export/apps as oppose to just /apps I see lots of other stuff. Can someone tell me the difference? Thanks (1 Reply)
Discussion started by: gillbates
1 Replies

2. UNIX for Dummies Questions & Answers

How does /export dir work?

In solaris I can switch to /export/appl/home or /appl/home to get to my home dir. If I switch to /export/apps as oppose to just /apps I see lots of other stuff. Can someone tell me the difference? Thanks (3 Replies)
Discussion started by: gillbates
3 Replies

3. UNIX for Dummies Questions & Answers

Can't get SSH to work without password

Need some help on this!! I've been trying to get SSH to work without having to enter a password. I've found numerous articles on this and have tried the instructions, but am still getting prompted for a password. One thing to mention is that I'm using different IDs on the two servers. Here's... (2 Replies)
Discussion started by: bradtri1
2 Replies

4. UNIX for Dummies Questions & Answers

SSH-KEYGEN doesn't work

Hi, Am running the following commands on our server to generate a key for passwordless SSH, however we are getting 100% blank key files. E.g. when looking id_dsa.pub or id_dsa they are 100% empty - the files get created, but contain no content and have a file size of 0b. mkdir ~/.ssh... (3 Replies)
Discussion started by: gjp
3 Replies

5. Shell Programming and Scripting

SSH shell script does not work

Hello I have a Zabbix Server were Linux kernel version 2.6.26-2-amd64 is running. now my Question how can i make a script that does: - connect with ssh to a device - get the systeminfo (but only the interfaces, mac adresses, serialnumber and Software version) - write the output in a file ... (18 Replies)
Discussion started by: Fraggy
18 Replies

6. IP Networking

Setting to SSH home-PC from Work

Hello, My question is very basic for the settings to SSH my home PC from work. Home network two PC: Internet comes into my house through ISP modem and then the two PCs are connected with the router (Trendnet). The IPs for my PCs are How to set other stuffs for me to access my home PC from... (5 Replies)
Discussion started by: yifangt
5 Replies

7. Shell Programming and Scripting

ssh does not work in script while running crontab

Hi All, I have prepared a small script to monitor few applications running on diff unix boxes(frontend/backed node1/node2 etc). ssh does not work for node2 when script executed from crontab..:wall: it work fine when i run it manually. Regards, Pavan (4 Replies)
Discussion started by: pavanchouksey
4 Replies

8. AIX

2nd SSH doesn't work with AD

Recently I decided to intall second daemon of SSH for Winbind users. I mean I have configuration AIX + Samba + AD and I can login to the server via SSH with AD accounts to 22 port without any problems. But now I have second installation of OpenSSH and don't understand why I can't do the same... (6 Replies)
Discussion started by: jess_t03
6 Replies

9. SuSE

SSH issue - can't get password less login to work

Hello, I can't seem to get the password less login to work on one of my SLES 11 servers. My ssh agent lets me login to all my other servers, which are Solaris 10, RHEL 5, and SLES 11 servers. Some servers mount my home directory and others don't. The server that I'm having an issue with doesn't... (7 Replies)
Discussion started by: bitlord
7 Replies

10. Shell Programming and Scripting

Ssh agent forwarding in script did not work

Sorry for the wrong question. (2 Replies)
Discussion started by: hce
2 Replies
BEL(1)                                                                                                                                      BEL(1)

NAME
bel - open a shell or execute a command on a remote computer through several machines SYNOPSIS
bel [-e file] [-s file] [-d delay] DESCRIPTION
bel generates a script allowing the user to open a shell or execute a command on a remote computer through several machines. In order to generate the script, the user gives the paths to the different machines until the final one is reached. Several paths may be specified in a single entry file or through the standard input. OPTIONS
-e, --entree=FILE Provide the necessary information to establish the tunnel between the source and the final computer. -s, --repertoire-sortie=DIRECTORY The directory where you want to put the generated scripts. -d, --delai=SECONDS Delay to wait before each sent command, in seconds. AUTHOR
Carl Chenet <chaica@ohmytux.com[]> RESSOURCES
Belier homepage : http://www.ohmytux.com/belier LICENSE
Copyright (C) <2009> <Carl Chenet>This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. 05/16/2009 BEL(1)
All times are GMT -4. The time now is 09:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy