10-07-2009
How to escape from the shell
In a Script I need to push several messages to a function.
My problem here is: I have to print the string v$LOCK on the resulting line which spits out the message. What I want here is not printing the contents of $LOCK I want to escape the shell and printout v$LOCK on the line. But don't know how to.
#!/bin/sh
AWK="/bin/awk"
RESULT="30"
DBPKG="vserver56"
message() {
${AWK} -F## '{system("echo \"" $1 "\" hostname='$DBPKG' severity=" $2 " sub_origin=\""$3"\" script=\"'$SCRIPT'\" \"" $4 "\" SENTRY")}'
}
echo "There is a session locking since $RESULT minutes. See v$LOCK!##CRITICAL##$METAGONIS_APPLICATION##GE_RPM_blocking_waits" | message
Spits out:
There is a session locking since 30 minutes. See v! hostname=vserver56 severity=CRITICAL sub_origin= script= GE_RPM_blocking_waits SENTRY
But should Spit out:
There is a session locking since 30 minutes. See v$LOCK! hostname=vserver56 severity=CRITICAL sub_origin= script= GE_RPM_blocking_waits SENTRY
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have got an application through which an user will submit an address like "c:\tuser\abc".
This application calls a script and passes the address to the scripts positional parameter say $1.
So $1 should contain "c:\tuser\abc", but when $1 is echoed the "\t" and "\a" are interpreted to... (4 Replies)
Discussion started by: puspendu
4 Replies
2. Shell Programming and Scripting
hey
i wanted to know if there is some single unix command to replace all the character escape sequences with their "C" values in a string...
The only way i know is repetatively kepp using the grep command for each one. (4 Replies)
Discussion started by: sahithi_khushi
4 Replies
3. Shell Programming and Scripting
Hi ,
I want to change space to ' in my script.
I tried doing this,
sed 's/ /\'/g' filename
but i could not get it.
can some one help me please.
Thanks,
Deepak (4 Replies)
Discussion started by: deepakpv
4 Replies
4. UNIX for Dummies Questions & Answers
Hi,
I would like to display the following message from my shell (Korn) script
Copy "old_file.txt" to "new_file.txt"
My code looks as follows
print "Copy "old_file.txt" to "new_file.txt""
However, when I execute the script, I get the following output
Copy old_file.txt to... (6 Replies)
Discussion started by: rogers42
6 Replies
5. Shell Programming and Scripting
Hi
I have 2 files like:
file1
a 12
b 1
a 3
file2
a 9
c 0
a 8
and i would like to get
a 12 a 9
a 3 a 8
i can do it with grep and paste with 3 lines. I tried to combine using: (3 Replies)
Discussion started by: Dedalus
3 Replies
6. Shell Programming and Scripting
I am trying to escape single quote in awk, but could not:
awk ' BEGIN{ fstr="COMPRESS('Y','N')" }
{
substr($1,len-3,4)~/_IND/
len=length($1)
if(substr($1,len-3,4)~/_IND/)
printf("%-32s%-14s%-5s%-14s\n",$1,$2,$3,$fstr,$4,$5,$6,$7)
}
' tt.txt > out.log
Error:
awk: Field... (8 Replies)
Discussion started by: ysvsr1
8 Replies
7. Shell Programming and Scripting
i am executing script from A server which will execute the script in B server , as below.
ssh A 'ssh B echo 'select * from testing where name ='test''
i am getting the below output.
select * from testing where name=test
but i need the output where clause with quotes , tried with... (3 Replies)
Discussion started by: expert
3 Replies
8. Solaris
Hello,
I am running Solaris 8. When issuing the command "stty lcase" all text which is output to the terminal are capitalized. Letters that are supposed to be capitals are preceded by a backslash during output. All text which is input is converted to lower case. This is the expected behaviour... (5 Replies)
Discussion started by: rstor
5 Replies
9. Shell Programming and Scripting
This is a bit off the wall, but I often need to run scripts where there are argument values that contain special characters.
For example,
$ ./process.exe -t M -N -o temp.mol.s -i ../molfiles/N,N\',N\'\'-trimethylbis\(hexamethylene\)triamine.mol && sfile_space_to_tab.sh temp.mol.s temp.s
It... (1 Reply)
Discussion started by: LMHmedchem
1 Replies
10. Shell Programming and Scripting
Hello,
Below script works fine when I manually enter required information for each file. When it comes to shell in auto mode, it gives various errors.
I am under ubuntu 14.04 / trusty.
manual_run.sh:
#!/bin/bash
/usr/bin/ffmpeg -start_at_zero -copyts -i nicki.mp4 -c:v mpeg2video \
-b:v 500k... (3 Replies)
Discussion started by: baris35
3 Replies
LEARN ABOUT CENTOS
addseverity
ADDSEVERITY(3) Linux Programmer's Manual ADDSEVERITY(3)
NAME
addseverity - introduce new severity classes
SYNOPSIS
#include <fmtmsg.h>
int addseverity(int severity, const char *s);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
addseverity(): _SVID_SOURCE
DESCRIPTION
This function allows the introduction of new severity classes which can be addressed by the severity argument of the fmtmsg(3) function.
By default that latter function only knows how to print messages for severity 0-4 (with strings (none), HALT, ERROR, WARNING, INFO). This
call attaches the given string s to the given value severity. If s is NULL, the severity class with the numeric value severity is removed.
It is not possible to overwrite or remove one of the default severity classes. The severity value must be nonnegative.
RETURN VALUE
Upon success, the value MM_OK is returned. Upon error, the return value is MM_NOTOK. Possible errors include: out of memory, attempt to
remove a nonexistent or default severity class.
VERSIONS
addseverity() is provided in glibc since version 2.1.
CONFORMING TO
This function is not specified in the X/Open Portability Guide although the fmtmsg(3) function is. It is available on System V systems.
NOTES
New severity classes can also be added by setting the environment variable SEV_LEVEL.
SEE ALSO
fmtmsg(3)
COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU
2008-06-14 ADDSEVERITY(3)