LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   script issues from suse to RHEL5 AS (https://www.linuxquestions.org/questions/linux-enterprise-47/script-issues-from-suse-to-rhel5-as-620964/)

pingpong 02-13-2008 08:41 PM

script issues from suse to RHEL5 AS
 
We recently migrated one server from SUSE OS to RHEL5. The problem is the shell scripts do not produce the desired outcome :confused: on the command line the output does not have any issues. Example:- S1=`cat $FILE1|grep -v /|grep [0-9]` from the prompt echo $S1 is 129 but code when fired in a script using bash or ksh outputs S1=$'129\r'. The same has been working fine on SUSE OS. Does this have to do with user profile/env etc?

Thnaks in advance for any valuable input :)

doublejoon 02-14-2008 06:17 AM

Quote:

Originally Posted by pingpong (Post 3056348)
We recently migrated one server from SUSE OS to RHEL5. The problem is the shell scripts do not produce the desired outcome :confused: on the command line the output does not have any issues. Example:- S1=`cat $FILE1|grep -v /|grep [0-9]` from the prompt echo $S1 is 129 but code when fired in a script using bash or ksh outputs S1=$'129\r'. The same has been working fine on SUSE OS. Does this have to do with user profile/env etc?

Thnaks in advance for any valuable input :)


Try
Code:

S1=$(/bin/cat $FILE1|/bin/grep -v /|/bin/grep [0-9])
I think the shell is trying to interpret those special characters in the command line substitution
So try the following for that

Code:

/bin/echo ${S1}


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