Need a help in the Shell script which is erroring out


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need a help in the Shell script which is erroring out
# 8  
Old 12-26-2007
sed^J/permission:/echo 'profile: /export/home/unix1/auto.pr' >> \$xxyy : not found

This is the error i am getting , any thing wrong in it

Thanks
# 9  
Old 12-26-2007
Can you post you script within code tags?
# 10  
Old 12-27-2007
Quote:
Originally Posted by ranga27
Hi all

I want to add this line after a line

This is the line which needs to be add after the word permission

echo 'profile: /export/home/unix1/auto.pr' >> $xxyy

if [ "$value" = "add" ];then
cd $unixserv/unix
sed '
/permission/ a\
echo 'profile: /export/home/unix1/auto.pr' >> $xxyy
generate_autosys_job.ksh > man5.txt

Can you please let me know what is the error

Its not adding the line as it is :echo 'profile: /export/home/unix1/auto.pr' >> $xxyy

Thanks

This is the one which i am using
# 11  
Old 12-28-2007
Quote:
Originally Posted by Franklin52
To output text within single quotes you can place the text within: single quote, double quote, single quote:

Code:
echo '"'profile: /export/home/unix1/auto.pr'"' >> $xxyy

Regards
Have you tried the solution I mentioned earlier?

Code:
sed '
/permission/ a\
echo '"'profile: /export/home/unix1/auto.pr'"' >> $xxyy' file

Regards

Last edited by Franklin52; 12-28-2007 at 11:05 AM.. Reason: Correct last line
# 12  
Old 12-28-2007
Yes i tried and it didnot worked

Thanks
# 13  
Old 12-28-2007
Hi.

I tried the solution of Franklin52:
Code:
#!/bin/sh -

# @(#) s2       Demonstrate sed insertion with complex quoting.

FILE=${1-data1}

echo
echo " Input file $FILE:"
cat $FILE

echo
echo " Results from sed:"
sed '
/permission/ a\
echo '"'profile: /export/home/unix1/auto.pr'"' >> $xxyy' $FILE

exit 0

producing:
Code:
% ./s2

 Input file data1:
This is a line
Another line
This line contains permission.
This is the line that should appear after the inserted line.
Last line.

 Results from sed:
This is a line
Another line
This line contains permission.
echo 'profile: /export/home/unix1/auto.pr' >> $xxyy
This is the line that should appear after the inserted line.
Last line.

So it works correctly for me. That means there are two solutions that appear to work correctly.

Writing:
Quote:
Originally Posted by ranga27
Yes i tried and it didnot worked
does not give us enough information.

Post the code you have tried and the results with copy and paste so that we can exactly what you have done, otherwise we're wasting time guessing what the problem might be ... cheers, drl
# 14  
Old 12-28-2007
Hi Thanks for the help ...

I have tried both the codes , it worked , but when i merging this with my script is not working


if [ "$value" = "add" ];then
sed '
/permission/ a\
echo 'profile: /export/home/unix/auto.profile-45' >> job_name_main man7.txt > man8.txt
echo "Profile added "


i am searching for the string permission in man7.txt and once found it should

add this line , can you give me simple code which can merged with if conditions

Thanks Guys !!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script newbie- how to generate service log from shell script

Hi, I am totally a newbie to any programming languages and I just started an entry level job in an IT company. One of my recent tasks is to create a script that is able to show the log file of linux service (i.e. ntpd service) lets say, if I run my script ./test.sh, the output should be... (3 Replies)
Discussion started by: xiaogeji
3 Replies

2. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. Shell Programming and Scripting

awk problem - erroring out - unexpected token

can anyone help identify where the issue is here? awk 'BEGIN { c="perl -e 'print scalar(localtime("'${EPOCHTIME}'")), "\n"'"; c|getline; close( c ); print $2" "$3" "$4" "$6; }' bash: syntax error near unexpected token `(' can't seem to figure it out. i tried this: awk 'BEGIN {... (5 Replies)
Discussion started by: SkySmart
5 Replies

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

6. Shell Programming and Scripting

Correct shell script to Call One shell script from another shell script

Hi All, I have new for shell scripting. Problem : I have one scrip at serv1 and path of server is /apps/dev/provimage/scripts and script name:extract_ancillary.bat. I need to call this script at server2(my working server) and execute at server2 . Please let me know how to build the... (5 Replies)
Discussion started by: Vineeta Nigam
5 Replies

7. Shell Programming and Scripting

How to use ssh execute other shell script on other host (shell script include nohup)?

i want use ssh on the host01 to execute autoexec.sh on the host02 like following : host01> ssh host02 autoexec.sh autoexec.sh include nohup command like follwing : nohup /home/jack/deletedata.sh & after i execute ssh host02 autoexec.sh one the host01. i can't found deletedata.sh... (1 Reply)
Discussion started by: orablue
1 Replies

8. AIX

mtime command erroring

I am calling this paramters from a controlfile CONTROLFILE="/u01/scripts/admin/filesystem.ctl" SEARCH_PATH="`grep SEARCH_PATH $CONTROLFILE | awk -F: '{print $2}' `" FILE_TYPE="`grep FILE_TYPE $CONTROLFILE | awk -F: '{print $2}' `" DEL_RETENTION_SIZE="`grep DEL_RETENTION_SIZE $CONTROLFILE |... (5 Replies)
Discussion started by: javeedkaleem
5 Replies

9. Shell Programming and Scripting

1 script 8 boxes and it is erroring on 3 of them

am trying to place a script from one hp11-unix box (where it works) onto three others where it won't. I am using csh and in the script I use the lines set F_SYSTEMS=(/dbs01 /dbs02 /dbm01 /dbm02 /ora_home/app/oracle) on this one the three others throw up on pulling the files. there should be... (2 Replies)
Discussion started by: cat55
2 Replies

10. UNIX for Advanced & Expert Users

DISPLAY variable erroring when installing Oracle 10g.

Hi, I'm trying to install Oracle 10g in Solaris 10. As required in the instructions, I set the DISPLAY variable: $ DISPLAY=192.168.150.128:0.0 ; export DISPLAY when run the runInstaller in a terminal, it displays an error related to DISPLAY variable. :( Any ideas?? Thanks. (2 Replies)
Discussion started by: ffpradella
2 Replies
Login or Register to Ask a Question