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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Unix Arithmatic operation issue , datatype issue thambi Shell Programming and Scripting 23 02-19-2008 04:19 AM
ftp issue ravi raj kumar Shell Programming and Scripting 5 02-06-2008 05:24 AM
awk issue on AIX ranj@chn Shell Programming and Scripting 1 07-04-2007 03:22 AM
Issue with rsh sriram.s AIX 5 07-03-2007 08:37 AM
FTP issue u263066 Shell Programming and Scripting 1 07-28-2006 03:18 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-09-2008
Registered User
 

Join Date: Feb 2008
Posts: 5
sh and csh issue

Hi

I like to assign a command string to a variable to execute.
In this case,

set sshexec_parent_pid="ps -ef | grep $$ | awk '/bash -c/ {print $3}' | sort | head -1;`"
echo $sshexec_parent_pid ;

But I can't seem to get it to work.
It gives me
sshexec_parent_pid: Undefined variable.


Originally, my sh looks like this and this works
sshexec_parent_pid=`ps -ef | grep $$| awk '/bash -c/ {print $3}' | sort | head -1;`
export sshexec_parent_pid ;
echo $sshexec_parent_pid ;

Does anyone know how to do that in csh ?

Advance thanks
Reply With Quote
Forum Sponsor
  #2  
Old 02-09-2008
Registered User
 

Join Date: Jan 2008
Posts: 328
why is there a backtik at the end of this line before the last double-quote?

set sshexec_parent_pid="ps -ef | grep $$ | awk '/bash -c/ {print $3}' | sort | head -1;`"

could that be causing a problem if it is in your real code?
Reply With Quote
  #3  
Old 02-10-2008
otheus's Avatar
Moderator ala Mode
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 653
Use eval to delay sbustitution of commands

Code:
$  test='\`echo "test worked"\`'
$ echo $test
\`echo "test worked"\`
$  test='echo "test worked"'
$  eval $test
test worked
$
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0