tcgetattr: Inappropriate ioctl for device after ssh command | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

tcgetattr: Inappropriate ioctl for device after ssh command

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-03-2011
jimmy75_13 jimmy75_13 is offline
Registered User
 
Join Date: May 2011
Last Activity: 12 August 2011, 10:30 AM EDT
Location: paris
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
tcgetattr: Inappropriate ioctl for device after ssh command

Hello everyone


I am finishing a script allowing me to purge logs on multiple servers, i have one last pb with the ssh command.........it is throwing me the following error :

tcgetattr: Inappropriate ioctl for device (full screen in attached file 1, full script in attached file 2)

It seems like i am unable to process command through SSH....;

conf: redHat 5.5 64 bit and GNU bash 3.1.17 on all servers, .sh script

thanks for you replies
Attached Thumbnails
-error_screen-png  
Attached Files
File Type: sh code.sh (2.6 KB, 10 views)
Sponsored Links
    #2  
Old 06-03-2011
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 16 September 2014, 1:48 PM EDT
Location: Southern NJ, USA (Nord)
Posts: 4,412
Thanks: 8
Thanked 540 Times in 518 Posts
If you want the commands to run remotely, they must go to the ssh commmand line or the ssh stdin.

Often, there is no point in a full ssh login, no need for a remote tty, so I:
Code:
( . . . . )|ssh user@host ksh

and write a ksh script to stdin.
Sponsored Links
    #3  
Old 06-03-2011
jimmy75_13 jimmy75_13 is offline
Registered User
 
Join Date: May 2011
Last Activity: 12 August 2011, 10:30 AM EDT
Location: paris
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Hi DGpicket

Thanks for your reply:

Quote:
If you want the commands to run remotely, they must go to the ssh commmand line or the ssh stdin.
If i put my remote server subroutine in a test.sh with 1 parameter and did this :

ssh jpassema@SERVER < test.sh $LE_PATH ?
    #4  
Old 06-03-2011
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 16 September 2014, 1:48 PM EDT
Location: Southern NJ, USA (Nord)
Posts: 4,412
Thanks: 8
Thanked 540 Times in 518 Posts
Not quite! < just sends the file down to run on whatever shell logs in, the argument does not make the trip. You can copy the script down there and then call it with an argument, or merge the argument into the script and pipe it all down to ssh. I recommend specifying the shell command as the recipient, so there is no full login. "ssh host" is a login, but "ssh host bash" is a pipe to a remote bash command running on host with no controlling terminal, much like a cron there. You need to build your own environment, as you can see if you run "ssh host bash -c set".
Sponsored Links
    #5  
Old 06-03-2011
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 18 September 2014, 11:01 PM EDT
Location: Saskatchewan
Posts: 19,375
Thanks: 788
Thanked 3,266 Times in 3,061 Posts
Quote:
Originally Posted by jimmy75_13 View Post
Hi DGpicket

Thanks for your reply:



If i put my remote server subroutine in a test.sh with 1 parameter and did this :

ssh jpassema@SERVER < test.sh $LE_PATH ?
Not quite. How about:


Code:
ssh jpassema@SERVER exec /bin/sh -b "$LE_PATH" < local-script.sh

By the by, it's usually not a good idea to name things test. UNIX already has a test utility that someone else might confuse it with.
Sponsored Links
    #6  
Old 06-03-2011
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 16 September 2014, 1:48 PM EDT
Location: Southern NJ, USA (Nord)
Posts: 4,412
Thanks: 8
Thanked 540 Times in 518 Posts
I do not think you need exec or full path for sh, and exec just saves a fork. What does -b do, put that value on the command line (hope it's a well behaved value)?
Sponsored Links
    #7  
Old 06-03-2011
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 18 September 2014, 11:01 PM EDT
Location: Saskatchewan
Posts: 19,375
Thanks: 788
Thanked 3,266 Times in 3,061 Posts
Quote:
Originally Posted by DGPickett View Post
I do not think you need exec or full path for sh, and exec just saves a fork.
A fork can be a thing worth saving, but yes, it's not strictly necessary.

The full path for a shell is just a habit of mine.
Quote:
What does -b do
That should have been -s, pardon me. Don't know how I managed the mixup when I was doublechecking in man pages as I typed!

-s forces it to read from standard input, which makes it treat parameters as script parameters $1 $2 etc instead of file names. It's a very portable option which seems to have been inherited from ancient bourne into bash, dash, ash, zsh, csh, ksh, and beyond.
The Following User Says Thank You to Corona688 For This Useful Post:
DGPickett (06-03-2011)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
mt command shows /dev/tape: inappropriate ioctl for device masterofdesaste UNIX for Dummies Questions & Answers 8 09-11-2008 10:09 AM
Inappropriate ioctl for device at contactme UNIX for Dummies Questions & Answers 0 03-26-2007 10:22 AM
Inappropriate ioctl for device steelrose UNIX for Dummies Questions & Answers 4 08-23-2006 10:08 AM
Inappropriate ioctl for device spoonman UNIX for Dummies Questions & Answers 0 08-23-2006 09:39 AM
Inappropriate ioctl for device tojaiganesh Filesystems, Disks and Memory 4 03-17-2005 04:23 PM



All times are GMT -4. The time now is 07:50 AM.