The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
returning to the parent shell after invoking a script within a script gurukottur Shell Programming and Scripting 5 09-26-2006 07:05 AM
Invoking Shell Script via php bubeshj Shell Programming and Scripting 2 06-30-2006 06:09 AM
Invoking shell script from html/jsp page bubeshj Shell Programming and Scripting 2 06-28-2006 01:53 PM
invoking one shell script from other ajay xavier Shell Programming and Scripting 3 05-24-2006 03:39 AM
invoking an Unix script from a C Program fermisoft High Level Programming 5 08-29-2005 09:34 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-24-2008
seeker333 seeker333 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 4
invoking script from /etc/passwd

Hi all,

i'm a newbie trying to accomplish probably a not so difficult task.
on my system, if an ssh connenction terminates i launch a telnet to 127.0.0.1. I changed the shell (command) in /etc/passwd to invoke a script that just does this, "telnet 127.0.0.1".

my /etc/passwd looks like

Code:
root:x:0:0:root:/:/myScript.sh
and my script is like

Code:
#! /bin/sh
#myScript.sh
if [ "$TERM" != "" ]
then
telnet 127.0.0.1
else
<???>
fi
now on receiving a sftp connection, when the TERM is not set, i just want the effect to be same as

Code:
root:x:0:0:root:/:/bin/sh
how can i accomplish this? what do i need to do in place of <???> so that it works?

Thanks in advance.

Last edited by Yogesh Sawant; 04-25-2008 at 03:35 AM.. Reason: added code tags
  #2 (permalink)  
Old 04-25-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Nothing, if you don't have any command after fi in your script, try this:

Code:
#!/bin/sh
#myScript.sh
if [ "$TERM" != "" ]; then
  telnet 127.0.0.1
fi
Regards
  #3 (permalink)  
Old 04-25-2008
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
First of all, I do not understand why you are doing this, but:
Code:
#!/bin/sh
#myScript.sh
if [ "$TERM" != "" ]
then
   telnet 127.0.0.1
else
   /bin/sh $*
fi
That's because when you sftp to a server, "-c /path/to/sftp-server" args are passed to the shell...

Regards.
  #4 (permalink)  
Old 04-25-2008
seeker333 seeker333 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 4
Grial, your suggestion works. Thanks!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:40 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0