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
SSH-ARGV0(1)						    BSD General Commands Manual 					      SSH-ARGV0(1)

NAME
ssh-argv0 -- replaces the old ssh command-name as hostname handling SYNOPSIS
hostname | user@hostname [-l login_name] [command] hostname | user@hostname [-afgknqstvxACNTX1246] [-b bind_address] [-c cipher_spec] [-e escape_char] [-i identity_file] [-l login_name] [-m mac_spec] [-o option] [-p port] [-F configfile] [-L port:host:hostport] [-R port:host:hostport] [-D port] [command] DESCRIPTION
ssh-argv0 replaces the old ssh command-name as hostname handling. If you link to this script with a hostname then executing the link is equivalent to having executed ssh with that hostname as an argument. All other arguments are passed to ssh and will be processed normally. OPTIONS
See ssh(1). FILES
See ssh(1). AUTHORS
OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt and Dug Song removed many bugs, re-added newer features and created OpenSSH. Markus Friedl contributed the support for SSH protocol versions 1.5 and 2.0. Jonathan Amery wrote this ssh-argv0 script and the associated documentation. SEE ALSO
ssh(1) Debian Project September 7, 2001 Debian Project
All times are GMT -4. The time now is 03:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy