Solved

executing /bin/sh script in a /bin/csh login

Posted on 1997-12-19
3
590 Views
Last Modified: 2013-12-26
I am initiating a shell script that goes out to various UNIX hosts to get system info.  I want to run the shell as bourne shell for the sake of uniformity.  

I initiate a shell script#1 on the local host.  Script#1 will do an rsh to the remote host, the remote host will mount itself to the local host and then call another script (script#2) that resides on the local host.  
The problem in a nutshell is that i want to run /bin/sh script in a /bin/csh environment and the #!/bin/sh flag does not seem to work.

The default ROOT login for the remote host is /bin/csh.  The problem is that when i login to the remote host it will not understand the script that has been written in bourne shell.  At the beginning of script#1 and script#2 i use the "#! /bin/sh" syntax.  
The remote host will not read the if [ ! -d $MOUNT_PT ]
                                       then  
                                        /bin/mkdir $MOUNT_PT
                                       fi

The errors that i get are as follows:

Remote: csns2
Missing ].
then: Command not found.
mkdir: /admin_mnt: File exists
fi: Command not found.
MOUNT_PT=/admin_mnt: Command not found.
export: Command not found.
HOST=csns2: Command not found.
export: Command not found.


I would appreciate any help that I could get.  I did read the comp.unix.shell FAQ and did see some differences btw. csh and sh but could not seem to get an answer to my problem.  
Thanks in advance.
rolf

SCRIPT #1

#! /bin/sh
   ...
   if [ "$OS" = SunOS ] && [ "$OSVER" = 4 ]
    then
      rsh $HOST "
       echo "Remote: $HOST"
     if [ ! -d $MOUNT_PT ]
     then  
        /bin/mkdir $MOUNT_PT
      fi
      /usr/etc/mount -t nfs nordic:$MOUNT_PATH $MOUNT_PT
      cd $MOUNT_PT
#      (setenv MOUNT_PT /admin_mnt;setenv HOST
$HOST;$MOUNT_PT/scripts/sunos_info.sh)
      (MOUNT_PT=/admin_mnt;export MOUNT_PT;HOST=$HOST;export
HOST;$MOUNT_PT/scripts/sunos_info.sh)
     cd /
      /usr/etc/umount $MOUNT_PT"
    fi
    ...

SCRIPT #2  (sunos_info.sh)

#! /sbin/sh -x
#######################################################
# FUNCTIONS
#######################################################
# disk space function for SUNOS
df_report () {
              if [ ! -d $MOUNT_PT/data/hosts/$HOST ]
              then
                mkdir $MOUNT_PT/data/hosts/$HOST
              fi

              /bin/df -t 4.2 | grep -v : >
$MOUNT_PT/data/hosts/$HOST/disk_space
              }
# END disk_space
#######################################################
df_report
0
Comment
Question by:rtrainor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:gormenghast
ID: 1295830
Hi
As a work around to this problem could you remove the rsh stuff from your initial script and edit it so that it can be run from the remote host. Then create another script which will rcp this script over to the remote host then run it from the remote host via an rsh.

#! /bin/sh
rcp scipt1 $HOST/tmp
rsh $HOST /tmp/script1

I haven't tried this out but it may work.
0
 
LVL 3

Expert Comment

by:rickyr
ID: 1295831
Hi...
I'm lagging behind you again gormenghast.
has anyone noticed that the second script refers to roots own private files?
#!/sbin/sh
As this is being started from another host, root logins may not be enabled, Do you really want people to be able to remotely login a root????
regards
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 200 total points
ID: 1295832
remote host has no  /sbin/sh
On either host (local or remote) you must make a link or copy of /bin/sh.
Keep rickyr's comment in mind ;-)
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Separate files macro - Errors on larger data set 18 73
difference between String.subString() and String.subSequence() 6 265
bigDiff challenge 17 134
Thin secure Windows 10 5 107
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question