The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Assigning output to a variable jpmena Shell Programming and Scripting 3 03-27-2008 04:39 AM
assigning nawk output to shell variable user_prady Shell Programming and Scripting 6 11-29-2007 04:01 AM
assigning command output to a shell variable kprattip Shell Programming and Scripting 2 07-09-2007 05:01 AM
Assigning output of command to a variable oma04 Shell Programming and Scripting 5 06-27-2006 01:11 PM
Assigning a shell variable as a float spieterman Shell Programming and Scripting 3 09-16-2002 10:02 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-28-2008
sankar reddy sankar reddy is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 6
Assigning output of command to a variable in shell

hi,
I want to assign find command result into some temporary variable:

jarPath= find /opt/lotus/notes/ -name $jarFile
cho "the jar path $jarPath"

where jarPath is temporary variable.

Can anybody help on this.

Thanks in advance
----Sankar
  #2 (permalink)  
Old 02-28-2008
manikantants manikantants is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 131
jarPath=`find /opt/lotus/notes/ -name $jarFile`
echo "the jar path $jarPath"
  #3 (permalink)  
Old 02-28-2008
sankar reddy sankar reddy is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 6
Quote:
Originally Posted by manikantants View Post
jarPath=`find /opt/lotus/notes/ -name $jarFile`
echo "the jar path $jarPath"

Hi,
Its not working...See i have written this code in some file called Notes.start

from bash i run like that ./Notes.start

its not giving any output....


Is there any constraints on different shell.I want to run the same file in AIX/Solaris/unix/linux.

and i am new this unix..

-sankar
  #4 (permalink)  
Old 02-28-2008
manikantants manikantants is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 131
this should work provided following are correct

Under /opt/lotus/notes/, there should be a file or directory with name in variable '$jarFile'.

Can you run the script in debug mode ? (give 'set -x' in the begining of the script) and paste the result here ?
  #5 (permalink)  
Old 02-28-2008
sankar reddy sankar reddy is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 6
Quote:
Originally Posted by manikantants View Post
this should work provided following are correct

Under /opt/lotus/notes/, there should be a file or directory with name in variable '$jarFile'.

Can you run the script in debug mode ? (give 'set -x' in the begining of the script) and paste the result here ?



file Name :::Notes_debug.start

set -x
jarFile=Notes.jar
if [ -f "$jarFile" ]; then
jarPath=`pwd`
fi
if [ $jarPath="" ]; then
jarPath= find /opt/lotus/notes/ -name $jarFile
echo "the jar path $jarPath"
fi


Output

+ jarFile=Notes.jar
+ [ -f Notes.jar ]
+ [ = ]
+ find /opt/lotus/notes/ -name Notes.jar
+ jarPath=
/opt/lotus/notes/65040/ibmpow/Notes.jar
+ echo the jar path
the jar path
  #6 (permalink)  
Old 02-28-2008
manikantants manikantants is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 131
In your script, i can see jarPath= find /opt/lotus/notes/ -name $jarFile
As I told you before please change this line to jarPath=`find /opt/lotus/notes/ -name $jarFile`


notice the backtick (backtick is with the tild key)
Closed Thread

Bookmarks

Tags
linux, solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0