SSH + multiple commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SSH + multiple commands
# 1  
Old 03-02-2012
SSH + multiple commands

Sorry for the basic question here, but I can't seem to find an answer anywhere. I want to alias a command that will ssh and then open up bbedit all in 1 command.

alias bbb 'ssh NAME@SERVER bbedit'

returns:
bash: bbedit: command not found

It returns this same thing for anything except super-basic commands such as "ls" or "pwd". So it's almost as if it's not initializing my .bashrc or something? I don't quite understand it.

This works:
alias bbb 'ssh NAME@SERVER open /Applications/BBedit.app'

but unfortunately I need the bbedit command-line tool to add other options.

Any help would be appreciated. Thanks!

ps. First post so sorry if this is in the wrong place.
# 2  
Old 03-02-2012
Code:
alias bbb='ssh NAME@SERVER "bbedit -p " '

where -p is an option of some sort.
This has problems -- aliases do not allow you to put a varying filename inside them
Create a function instead. call the function bbb. Put the following in your login directories .profile or .bashrc, so the next time you login it will work. Add options to bbedit in the code if you need them (where "-p" is in the code)

Code:
# bbb bbedit on a remote box
# usage bbb filename_to_edit
bbb()
{
    mycmd=$( printf "ssh name@server 'bbedit -p %s'"  "$1")
    eval $mycmd
}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Ssh script to validate ssh connection to multiple serves with status

Hi, I want to validate ssh connection one after one for multiple servers..... password less keys already setup but now i want to validate if ssh is working fine or not... I have .sh script like below and i have servers.txt contains all the list of servers #/bin/bash for host in $(cat... (3 Replies)
Discussion started by: sreeram4
3 Replies

2. Shell Programming and Scripting

Ssh multiple hops to execute commands with arguments

Hi I need to write a script to ssh through several hops (e.g. HostA-HostB-HostC-HostD), where Host A does not have direct assess to HostC ; HostB cannot access HostD directly. when I ssh 3 hops and run command with arg1, arg2 and redirect the output to a file, e.g. HostA> ssh -t HostB ssh -t... (3 Replies)
Discussion started by: chiensh
3 Replies

3. UNIX for Advanced & Expert Users

Pass Multiple Commands and Open Multiple Xterms via PSS

Hello, I'm attempting to open multiple xterms and run a command as an SAP user via sudo using PSSH. So far, I'm able to run PSSH to a file of servers with no check for keys, open every xterm in to the servers in the file list, and SUDO to the SAP(ADM) user, but it won't do anything else... (11 Replies)
Discussion started by: icemanj
11 Replies

4. Shell Programming and Scripting

Run multiple commands in ssh

Hi All, I have the below requirement. I want to copy the local file to remote after that i need to run the local script on a remote machine.When i use two ssh commnds i can achieve this. But i want to achieve this using one ssh command. Below command to copy the local file to remote ssh -q... (2 Replies)
Discussion started by: mohanalakshmi
2 Replies

5. Shell Programming and Scripting

Executing multiple ssh commands inside a shell simultaneously

I would like to execute a commands in four different servers through ssh at a single instance(simultaneously). Below are the details with examples, ssh user1@server1 "grep xxxx logs" ssh user1@server2 "grep xxxx logs" ssh user1@server3 "grep xxxx logs" Each statement will take some... (4 Replies)
Discussion started by: Amutha
4 Replies

6. Shell Programming and Scripting

perform 3 awk commands to multiple files in multiple directories

Hi, I have a directory /home/datasets/ which contains a bunch (720) of subdirectories called hour_1/ hour_2/ etc..etc.. in each of these there is a single text file called (hour_1.txt in hour_1/ , hour_2.txt for hour_2/ etc..etc..) and i would like to do some text processing in them. Each of... (20 Replies)
Discussion started by: amarn
20 Replies

7. Shell Programming and Scripting

connect to multiple servers using SSH and execute commands

Requirement: Run a shell script with below inputs file name checksum path the script should go to multiple servers (around 35) and verify the input cksum and if there is a mismatch display a simple message to the user that cksum verification failed. host details, user id /... (1 Reply)
Discussion started by: amicableperson
1 Replies

8. Shell Programming and Scripting

Bash commands to an 'ssh' within an ssh'

I've struggled to find a solution to this problem from searching so I thought I'd write a post to see what can be done. I'm attempting to connect and run commands on 'server2' but because of security limitations I cannot access it directly. I can however ssh into 'server1' and then into... (7 Replies)
Discussion started by: mcintosh.jamie
7 Replies

9. Shell Programming and Scripting

could not send commands SSH session with Net::SSH::Expect

I am using Net::SSH::Expect to connect to the device(iLO) with SSH. After the $ssh->login() I'm able to view the prompt, but not able to send any coommands. With the putty I can connect to the device and execute the commands without any issues. Here is the sample script my $ssh =... (0 Replies)
Discussion started by: hansini
0 Replies

10. Shell Programming and Scripting

Expect, SSH and multiple passed commands

Hey Everyone, I have found this script online that has almost all the features I am looking for. However, I do not know enough expect to debug the problem. http://linuxgazette.net/100/misc/tips/sshtool.expect.txt First, it Traps out after it collects the user's password. I do not know... (0 Replies)
Discussion started by: patchsmyle
0 Replies
Login or Register to Ask a Question