variable assigment not works in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting variable assigment not works in shell script
# 1  
Old 03-28-2012
variable assigment not works in shell script

Hi,
The following assigment is not working within shell script but is working from command line. Could anybody advise why? OS - solaris 8
Code:
APPL=`grep "$Application" ldapapps |awk '{print $1}'`
echo $APPL

# 2  
Old 03-28-2012
Not quite sure, but try using the full path for grep, like
Code:
/usr/bin/grep

and see what happens.
# 3  
Old 03-28-2012
Code:
APPL=`grep "$Application" ldapapps |awk '{print $1}'`
echo $APPL

Is ldapapps a variable. If it is then it should be represented by ${ldapapps}.
# 4  
Old 04-02-2012
ldappapps is a simple plaintext file.
Any suggestions?
# 5  
Old 04-02-2012
What means "does not work"? I guess you get nothing displayed or do you get an error..?

As you say that it works on the command line, please show the output of it, thanks.

Is $Application set in the script you are trying the variable assignment in?

Last edited by zaxxon; 04-02-2012 at 10:14 AM.. Reason: changing "shell" vs. "script" in 3rd line
# 6  
Old 04-02-2012
Did you set the variable $Application?
Is the variable with a capital A?
did you spell correctly? ldapapps vs. ldappapps
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace string works on command-line but fails when run from shell script

I wish to replace "\\n" with a single white space. The below does the job on command-line: $ echo '/fin/app/scripts\\n/fin/app/01/sql' | sed -e 's#\\\\n# #g'; /fin/app/scripts /fin/app/01/sql However, when i have the same code to a shell script it is not able to get me the same output:... (8 Replies)
Discussion started by: mohtashims
8 Replies

2. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

3. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

4. Shell Programming and Scripting

Assignment with variable assigment

Hello All, I'm trying to assign integer values to variables using substitution in both the value and variable's name, i.e., number$x=$x where x is equal to one in the first assignment, two in the second assignment, and so on with x being incremented each time. However, when I do the... (7 Replies)
Discussion started by: tombombadil
7 Replies

5. Shell Programming and Scripting

perl: Command works in terminal, but not in shell script

Hi, the following command works in the terminal no problem. samtools view -h rawlib.bam | perl -ne '{ @line = split( /\s+/ ); $match = 0; while( $line =~ /(\d+)M/g ) { $match = $match + $1 } if( $match >= 80 || $_ =~ /^\@/ ) { print $_ } }' | java -Xmx12G -jar... (8 Replies)
Discussion started by: jdilts
8 Replies

6. Shell Programming and Scripting

SH script, variable built command fails, but works at command line

I am working with a sh script on a solaris 9 zone (sol 10 host) that grabs information to build the configuration command line. the variables Build64, SSLopt, CONFIGopt, and CC are populated in the script. the script includes CC=`which gcc` CONFIGopt=' --prefix=/ --exec-prefix=/usr... (8 Replies)
Discussion started by: oly_r
8 Replies

7. Shell Programming and Scripting

how the typeset command works in shell script

typeset -l section section=${2:-.} what does these 2 lines meaning? (1 Reply)
Discussion started by: venkatababu
1 Replies

8. Shell Programming and Scripting

Works in shell but not script UNIX

ok i have a very simple UNIX script #!/bin/bash TERM=ansi;export TERM PFCMARK=25;export PFCMARK umask 0000 PFUMASK=000;export PFUMASK #run for filepro menus and exectuables echo "###########File Modification Log.############\r" > "/public/appl-fp$(date +%m-%d-%Y).txt" find /appl/fp/... (10 Replies)
Discussion started by: dunpealslyr
10 Replies

9. Shell Programming and Scripting

assign awk's variable to shell script's variable?

Dear All, we have a command output which looks like : Total 200 queues in 30000 Kbytes and we're going to get "200" and "30000" for further process. currently, i'm using : numA=echo $OUTPUT | awk '{print $2}' numB=echo $OUTPUT | awk '{print $5}' my question is : can I use just one... (4 Replies)
Discussion started by: tiger2000
4 Replies

10. Shell Programming and Scripting

Execution issue with shell script - works in a different environment

Hi I get the following error while executing the shell script. I did not get an error when I ran the script in a different environment (unix server). str-token.ksh: 0403-057 Syntax error at line 20 : `(' is not expected. This is the line which gives error string=(${pos_array}) Please find... (3 Replies)
Discussion started by: hidnana
3 Replies
Login or Register to Ask a Question