LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-07-2015, 10:15 AM   #1
asteroid4u
Member
 
Registered: Jun 2015
Posts: 58

Rep: Reputation: Disabled
setenv command not found in shell script


Hi Guys,

I am facing problem in my shell script setenv command not find.

user uses tcsh shell

Below is my code

[code}
#!/bin/sh
#get Directories informations
arg3=`pwd`
cd ..
mkdir -p lint/reports_India
arg5=`pwd`
cd ../..
arg4=`pwd`

#ssh remote host and pass agrguments
sshpass -p 'abc' ssh -o StrictHostKeyChecking=no l abc@machine1 sh -x /home/lint/lint-us.sh $1 $2 $arg3 $arg4 $arg5
[code]

Remote host script:
[code]
#!/bin/sh
echo $SHELL
#get total fields by spliting /
T_field=`echo "$3" | awk -F"/" "{ print NF }"`
#Get second and fourth field names
a=1
b=3
Second="$((T_field - a))"
Fourth="$((T_field - b))"
F_field=`echo "$3" | cut -d'/' -f$Fourth`
S_field=`echo "$3" | cut -d'/' -f$Second`
cd /home/lint/project/t6/T6_USLint/
echo "$4"
#get only directories
ls -d */ > /home/lint/output
while read line
do
cd $line
hg pull; hg update
cd ..
done < /home/lint/output
#sync data
rsync -av root@xyz:$4/ /home/lint/project/t6/T6_USLint/; hostname; whoami
echo $SHELL
#sshpass -p 'cdrom88' ssh -o StrictHostKeyChecking=no root@vnc55 rsync -av -e ssh root@vnc55:$4/ /home/lint/project/t6/T6_USLint/
echo "`pwd`"
path=`pwd`
setenv DESIGN $path
echo "$DESIGN"
setenv RTL $path/rtl
setenv VERIF $path/verif
echo "$VERIF"
setenv MAKETOOLS $path/maketools
setenv IPDIR $path/ipdir
/usr/bin/perl /home/lint/project/t6/T6_USLint/maketools/setprod.pl $1
[code]

Since user uses tcsh shell and script is in sh. So I have tried insteadof setenv DESIGN $path export DESIGN=$path
but script is hanging near
/usr/bin/perl /home/lint/project/t6/T6_USLint/maketools/setprod.pl $1

Please help
 
Old 12-07-2015, 10:32 AM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,157

Rep: Reputation: 857Reputation: 857Reputation: 857Reputation: 857Reputation: 857Reputation: 857Reputation: 857
The closing code tag should be [/code]

Are you sure /bin/sh points to tcsh? Try using #!/bin/tcsh ( presuming tcsh is in bin ) Some shells like BASH ( I don't know about tcsh ) will allow/force slightly different syntax/comands when called as /bin/sh, in BASH this make BASH act 'posixly', is that a real word?
 
Old 12-07-2015, 10:56 AM   #3
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Rep: Reputation: 111Reputation: 111
unless done on purpose, I'm not aware of a system that links /bin/sh to 'tcsh'; since this shell is not one of the most commonly used (ksh and bash are the most common used, I guess) it would be good to verify which shell is actually used. The shebang forces the use of this shell, so the user shell has no impact on this script.

@Keith Hedger, I have seen the word 'posixly' in various contexts; my only guess is that it is a valid term :-)

Anyway; you say the script hangs at or near the call to the perl script; What does this perl script do, and how do you know it hangs?

have you tried to 'debug' using 'set -x' to see what actually happens inside your script; a small typo can collapse your entire setup :-)
 
Old 12-07-2015, 07:24 PM   #4
asteroid4u
Member
 
Registered: Jun 2015
Posts: 58

Original Poster
Rep: Reputation: Disabled
Hi,

Yes even i thought user shell wont cause any impact on this script.


1. when i use export the script hangs at /usr/bin/perl /home/lint/project/t6/T6_USLint/maketools/setprod.pl $1 i tested with sh -x script

2.When i use setenv it says command not found and /usr/bin/perl /home/lint/project/t6/T6_USLint/maketools/setprod.pl $1 says set product variables.

3. I have tested manually its works fine. I have tested each command in user tcsh shell prompt.So its says there is problem in perl script
Now I have one option i need to use #!/bin/tcsh and translates script to tcsh syntax or any other option to fix this problem
 
  


Reply



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
command not found error while executing a shell script SurbhiJain Linux - Newbie 15 07-26-2010 09:18 AM
running shell script: command not found tripat Red Hat 3 04-14-2010 01:21 PM
-bash: setenv: command not found Raakh Linux - Newbie 2 07-17-2007 09:59 AM
bash: setenv: command not found anobansa Linux - Newbie 4 09-29-2006 02:16 AM
command not found (My shell script) Swift&Smart Linux - Software 3 05-15-2004 11:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:24 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