LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-05-2010, 11:18 AM   #1
Vanyel
Member
 
Registered: Jul 2007
Location: NY, NY
Distribution: RHEL, CentOS, MacOS X
Posts: 158

Rep: Reputation: 29
Problem executing linux command remotely


If I type this manually on the command line, it works

Quote:
ssh -Y user@machine 'firefox &'
I ssh into the remote machine as the named user and pop an instance of firefox from that machine back to my own.

If I put the same thing into a shell script though, it fails.

Quote:
#!/bin/bash

ssh -Y user@machine 'firefox &'
I'm just left sitting at a command line on the remote machine.

I'm stumped. Why does the script fail and how can I make it work?
 
Old 10-05-2010, 09:14 PM   #2
carltm
Member
 
Registered: Jan 2007
Location: Canton, MI
Distribution: CentOS, SuSE, Red Hat, Debian, etc.
Posts: 703

Rep: Reputation: 99
I'm not sure why it doesn't work, but I use this in a script:

Code:
ssh -Y $User@$Host "firefox -no-remote" "$@" >/dev/null &
Give this a try to see if the -no-remote and moving the
ampersand makes any difference.

Last edited by carltm; 10-05-2010 at 09:15 PM. Reason: typo
 
Old 10-07-2010, 03:15 PM   #3
Vanyel
Member
 
Registered: Jul 2007
Location: NY, NY
Distribution: RHEL, CentOS, MacOS X
Posts: 158

Original Poster
Rep: Reputation: 29
Thanks for the response.

Don't entirely understand your snippet. What's the "$@" for?

- Van
 
Old 10-07-2010, 05:08 PM   #4
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
It handles any arguments you pass to your script (other commands). Google "bash arguments $@".
 
Old 10-08-2010, 06:51 PM   #5
carltm
Member
 
Registered: Jan 2007
Location: Canton, MI
Distribution: CentOS, SuSE, Red Hat, Debian, etc.
Posts: 703

Rep: Reputation: 99
Yes, a lot of people know that "$*" contains the list of arguments entered
at the command line. However, $* will delimit the arguments with a space.
Using $@ you also get the original delimiters, which could be any whitespace
that by default is any space, tab or newline.

In most cases $* works as well as $@, but I like to pass the exact string
that was entered at the command line.
 
  


Reply

Tags
sshscriptbash



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing commands remotely using scripts imagine_me2 Linux - Newbie 10 07-09-2010 12:09 PM
executing db2diag remotely engee AIX 3 11-30-2009 09:27 AM
Executing a *.bin file remotely on Linux AndrewNew Linux - Newbie 3 05-15-2008 05:38 AM
Problem executing from command line jleyba213 Linux - General 4 04-09-2004 12:43 PM
Executing X-Programs remotely frankieboy Linux - General 3 10-08-2003 02:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration