Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command doesn't work inside a shell script

Status
Not open for further replies.

tulsantide

Technical User
Jun 1, 2015
21
0
0
US
Hi,

I tried the following command outside a script on a Linux system and it works perfect. The same command worked inside the script as well, but it suddenly stopped working. I tried different ways but no luck. Please advice!
=============================================
ls /appl/user1/build|grep "20160307112214"

output is build_20160307112214.war

==========================
shell script
==========================
#!/bin/sh
w_tmstamp=`grep tag /appl/user1/deploy/props/env.properties|awk -F"_" '{print $3}'` # the output of this is 20160307112214
war_file=`ls /appl/user1/build|grep $w_tmstamp` # output of this should be build_20160307112214.war but when i do echo $war_file the output is empty.
 
The same command worked inside the script as well, but it suddenly stopped working. I tried different ways but no luck. Please advice!

I would advise that you investigate what has changed on the machine in question during the period between it working and it not working.

Any other advice would be simply guesses.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Thanks Chris.
I found that ^M characters got introduced in env.properties file. Script started working after running dos2unix command against the same property file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top