Issues with expr command on Solaris Box


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issues with expr command on Solaris Box
# 1  
Old 06-09-2010
Question Issues with expr command on Solaris Box

Hello Friends,

I have written a code on a Linux box, however, am getting issues while running it on a Solaris server. The issue with Sed command is sortd out, however, am still lokking for solutions with expr command. Here is the issue,

Linux :

Code:
 bash-2.03$ expr match singh@test.com '\(^[a-zA-Z0-9\w\.\_\-]*@[Tt][Ee][Ss][Tt].[Cc][Oo][Mm]$\)'
singh@test.com
bash-2.03$

Solaris :

Code:
bash-2.03$ expr match singh@test.com '\(^[a-zA-Z0-9\w\.\_\-]*@[Tt][Ee][Ss][Tt].[Cc][Oo][Mm]$\)'
bash-2.03$

The output in solaris is blank. Could anyone please let me know what changes can I make in this command to make it work.

Any suggestions would be greatly appreciated !!!

Moderator's Comments:
Mod Comment Please use code tags, ty

Last edited by pludi; 06-09-2010 at 06:29 AM..
# 2  
Old 06-09-2010
Quote:
Originally Posted by suffisandy
Hi All, I am facing similar issues with expr command on solaris box. I have created a new thread as well for the issue. Here is the thread contents

Hello Friends,

I have written a code on a Linux box, however, am getting issues while running it on a Solaris server. The issue with Sed command is sortd out, however, am still lokking for solutions with expr command. Here is the issue,

Linux :

bash-2.03$ expr match singh@test.com '\(^[a-zA-Z0-9\w\.\_\-]*@[Tt][Ee][Ss][Tt].[Cc][Oo][Mm]$\)'
singh@test.com
bash-2.03$

Solaris :

bash-2.03$ expr match singh@test.com '\(^[a-zA-Z0-9\w\.\_\-]*@[Tt][Ee][Ss][Tt].[Cc][Oo][Mm]$\)'
bash-2.03$

The output in solaris is blank. Could anyone please let me know what changes can I make in this command to make it work.

Any suggestions would be greatly appreciated !!!
You may want to try one of these perhaps.

Code:
gaurav@localhost:~$ echo singh@test.com | perl -wlp -e '/^\S+\@test.com/i'
singh@test.com

Test your i/ps with this . "-i" stands for case-insensitive. so it makes your regex less ugly. code your stuffs in perl if you want them portable would be my advise.

Regards,
Gaurav.
# 3  
Old 06-09-2010
Don't have a solaris but try to use the comparison operator : instead of its alias.

Code:
bash-2.03$ expr singh@test.com : '\(^[a-zA-Z0-9\w\.\_\-]*@[Tt][Ee][Ss][Tt].[Cc][Oo][Mm]$\)'

# 4  
Old 06-09-2010
Need to make exact match

Hi Gaurav,

Thanks for the suggestion. Am not familiar with Perl Scripting, however, now I am plannig to study it as well. Could you please let me know how can I make exact pattern match, for instance singh@test.coms should not be matched. (there is an extra "s" after com).

---------- Post updated at 06:53 AM ---------- Previous update was at 06:51 AM ----------

@Ripat

That option did not worked Smilie
# 5  
Old 06-09-2010
Why don't you try with grep:


Code:
~$ echo 'singh@test.com' | grep -qi '^[a-z0-9_-.]\+@test\.com$' && echo 'got a match' || echo 'failed'

> got a match



$ echo 'singh@test.coms' | grep -qi '^[a-z0-9_-.]\+@test\.com$' && echo 'got match' || echo 'failed'

> failed

# 6  
Old 06-09-2010
Quote:
Originally Posted by suffisandy
Hi Gaurav,

Thanks for the suggestion. Am not familiar with Perl Scripting, however, now I am plannig to study it as well. Could you please let me know how can I make exact pattern match, for instance singh@test.coms should not be matched. (there is an extra "s" after com).

---------- Post updated at 06:53 AM ---------- Previous update was at 06:51 AM ----------

@Ripat

That option did not worked Smilie
Hi. thats simple regex modification. put a "$" (end of line) after com. for example

Code:
gaurav@localhost:~$ echo singh@test.coms | perl -wln -e 'print if /^\S+\@test.com$/i'
gaurav@localhost:~$ echo singh@test.com | perl -wln -e 'print if /^\S+\@test.com$/i'
singh@test.com
gaurav@localhost:~$

Hope you get the point.
Regards,
Gaurav.
# 7  
Old 06-09-2010
Quote:
Originally Posted by gaurav1086
[code]
gaurav@localhost:~$ echo singh@test.coms | perl -wln -e 'print if /^\S+\@test.com$/i'
gaurav@localhost:~$ echo singh@test.com | perl -wln -e 'print if /^\S+\@test.com$/i'
singh@test.com
gaurav@localhost:~$
[/code

This pattern /^\S+\@test.com$/i will match anybody@testscom. Shouldn't the dot be escaped?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Issues with 'expr'

Hi, I have a text file where i define all the inputs to my shell script: IP=1.2.3.4 PC=1234 In the shell script, i am trying to read the input variables from the above mentioned text file: #!/bin/bash #usage IP=expr cat /tmp/input.txt | grep IP| cut -d "=" -f2 PC=expr cat... (4 Replies)
Discussion started by: akarnya
4 Replies

2. Shell Programming and Scripting

Issues for script that login to a unix box

Hi, I have a script that should login to a different box then the box that i am in and run the commands. I have the script sample below that logins to a unix box and get the files .Looks like ls-lrt command is not running or its wrongly used. #!/bin/bash # Ask the user for build month... (5 Replies)
Discussion started by: learninguser235
5 Replies

3. Solaris

Reboot solaris box(What are all the command outputs)

Hi What are all the command outputs we have to note and keep it for safe before rebooting or shutting down a solaris box (5 Replies)
Discussion started by: newtoaixos
5 Replies

4. UNIX for Dummies Questions & Answers

DNS on Unix box issues

Hi Guys, Just wanted to seek your assistance on an issue encountered with one of our client DNS server query. we have 2 sets of DNS servers.. internal and external. For Internal to reach the external DNS server (DMZ) it has to go through 2 FWs. Current settings: - FW rules for Internal... (3 Replies)
Discussion started by: Hotshot8259
3 Replies

5. UNIX for Dummies Questions & Answers

Transferring files Permission issues in remote box

Hi, I have a directory 'data' which is a symbolic link to /var/opt/store/rawdata/appname on a remote box. I am not able to SFTP some files from my local box to this dir. in the remote box. Also I am not able to copy or move the files in the robot id home dir. in remote box to this data dir... (2 Replies)
Discussion started by: vharsha
2 Replies

6. Shell Programming and Scripting

Expr issues

I have two variables that are set by a number i.e. recs_on_db=12 yesterdays_recs_on_db=10 i need to get the difference between the two and be able to set this in a variable I have tried expr but does not work: db_difference=`expr $recs_on_db - $yesterdays_recs_on_db` i get: expr:... (2 Replies)
Discussion started by: Pablo_beezo
2 Replies

7. Shell Programming and Scripting

expr inside a ksh script Solaris

Hi; If I do something like this. dftotalsize=0;export dftotalsize;df -k | grep \/db001 | awk '{print $4}' | while read theinput \ ; do export $theinput; dftotalsize=`expr $dftotalsize + $theinput`; export dftotalsize; echo $dftotalsize; done ; echo `expr $dftotalsize \/ 1024 \/ 1024 "GB" Is... (4 Replies)
Discussion started by: myjess
4 Replies

8. UNIX for Dummies Questions & Answers

I need an scp command from a unix box to a windows box.

scp file="myfile.txt" todir="user@somehost:(M:drive:/somepath/)"/ Not sure I need it to go to a specific drive on the windows box (1 Reply)
Discussion started by: xgringo
1 Replies

9. UNIX for Dummies Questions & Answers

difference between AIX box and Sun Solaris box

Hi, I need a clarification. Is there any difference between AIX box and Sun Solaris box? The bzip command with -c option works in AIX box and the same does not work in Sun Solaris box. Can anyone please explain if there is an implementation difference in both these boxes for the shell... (1 Reply)
Discussion started by: nisha4680
1 Replies

10. UNIX for Dummies Questions & Answers

how to mount a hotswap scsi drive on a solaris 2.6 netra box using the mount command?

Hi... question is this: How do I mount an LVD hotswap scsi drive in bay #2 on a netra using the mount command? volmgt doesn't seem to mount it and/or I don't know how to view the drives data if it's formatted which it may not be. This drive is not new out of the box so I'm not sure. ... (4 Replies)
Discussion started by: soulshaker
4 Replies
Login or Register to Ask a Question