Sponsored Content
Top Forums Shell Programming and Scripting What's the correct syntax to use "if-else" Post 302369101 by elsa on Friday 6th of November 2009 12:46:56 PM
Old 11-06-2009
Power What's the correct syntax to use "if-else"

hi, i'm a beginner in Linux, actually i use andLinux,
i have a data file with 11 columns
Code:
170 N  SER T 25 56.962 42.701 -133.423 1.00 87.04 N
171 CA SER T 25 57.076 41.790 -132.280 1.00 86.65 C
172 C  SER T 25 57.766 40.492 -132.692 1.00 87.52 C
173 O  SER T 25 58.653 39.988 -131.992 1.00 86.59 O
174 CB SER T 25 55.694 41.451 -131.730 1.00 85.78 C
175 OG SER T 25 54.981 40.607 -132.622 1.00 77.49 O

i would like write close to 11 th column "12" if in the 11 th column is C or "14" if is N or "16" if is O,
i tried several time only for C but doesn't work
Code:
{ 
atom = $11
if  ( atom == " C " ) 
{ 
  print  $11 12
} 
else
{ 
  print  $11 "no" 
}
}

Can somebody help me???
thanks

Last edited by Franklin52; 11-06-2009 at 05:52 PM.. Reason: Adding code tags and aligning code
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

correct syntax for using "grep regex filename" ?

I'm trying to grep a long ls by looking at the beginning of each filename for example: Many files begin with yong_ho_free_2005... Many files begin with yong_ho_2005... I can't just use "grep yong_ho" otherwise It'll display both files. So I'm trying to use a regex but my syntax is wrong. ... (2 Replies)
Discussion started by: yongho
2 Replies

2. Shell Programming and Scripting

Pls correct the "if" syntax

Iam a learner of UNIX. Fortunately I got this site. I want to check the file for its existance. if echo " Not present" else echo "Present" fi The above code is working fine. But I also want to check for the files which are compressed. I tried the following code and it is not... (5 Replies)
Discussion started by: ganapati
5 Replies

3. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

4. Shell Programming and Scripting

Need Correct syntax for "if" in UNIX

I am trying to write a simple if statement but that driving me crazy:eek: with syntactical erorrs. This is what I managed to come up #!/bin/ksh USERNAME=`whoami` if ;then echo " you have logged in as report user" elif ; then echo " you have logged in as extract user" else " I dont... (3 Replies)
Discussion started by: kkb
3 Replies

5. Shell Programming and Scripting

Compare file names and select correct elements to include in "for each loop"

Hi everyone, I`ll try to be most clear I can explaining my help request. I have 2 folders Folder A-->This folder receives files through FTP constantly Folder B-->The files from Folder A are unzipped and then processed in Folder B Sometimes Folder A doesn`t contain all... (2 Replies)
Discussion started by: cgkmal
2 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. OS X (Apple)

"Permission denied" when trying to SSH my iPhone though password is correct

Hi, I hope this is the correct section in the forum to post as I'm trying to SSH from my MacBook. I was looking to see whether ssh on my jailbroken iPhone 6s (10.3.1) still works fine and was following this old reddit guide. I installed OpenSSH&OpenSSL from Cydia and changed the password using... (7 Replies)
Discussion started by: hss1
7 Replies

8. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
RTPPROXY(8)							  [FIXME: manual]						       RTPPROXY(8)

NAME
rtpproxy - RTP (Real-time Transport Protocol) Proxy Server SYNOPSIS
rtpproxy [-?] [-2] [-f] [-v] [-R] [-l addr1[/addr2]] [-6 addr1[/addr2]] [-s ctrl_socket] [-t tos] [-p pidfile] [-T max_ttl] [-r rdir [-S sdir]] DESCRIPTION
rtpproxy is a symmetric RTP proxy designed to be used in conjunction with the SIP Express Router (SER) or any other SIP proxy capable of rewriting SDP bodies in SIP messages that it processes. The main purpose of rtpproxy is to make the communication between SIP user agents behind NAT(s) (Network Address Translator) possible. Several cases exists when direct end-to-end communication is not possible and RTP streams have to be relayed through another host. Rtpproxy can be used to setup such a relaying host. When two listen interfaces have been specified using the command line parameters described below then rtpproxy will enter so called bridging mode. In briding mode rtpproxy forwards RTP packets received on one interface to the other interface and vice versa. This mode can be used to forward RTP packets between networks without direct network level connectivy (provided that the host running rtpproxy has one interface in both of them). One particular application of bridging mode is IPv4/IPv6 traversal of RTP packets. When instructured by SER rtpproxy can also record the entire RTP session in a file on a local harddisk or play a pre-recorded file to the user agent (so called Music-on-Hold). OPTIONS
-? Show summary of options. -2 Send every RTP packet twice in sessions that use low-bitrate codecs. Only packets that are smaller than 128 bytes will be sent twice. This option can improve audio quality on lossy links. -f Rtpproxy will stay in foreground mode if this option is set. -v Show version of program. -l addr1[/addr2] IPv4 listen IP address(es). You can specify either one or two addresses. If two addresses have been specified then rtpproxy will work in bridging mode. -6 addr1[/addr2] IPv6 listen IP address(es). You can specify either one or two addresses. If two addresses have been specified then rtpproxy will work in bridging mode. -s ctrl_socket This parameter configures rtpproxy control socket. The control socket is used by nathelper module of SER to create/modify/delete RTP sessions to be relayed. Format of ctrl_socket is <type>:<socket>. Following types are supported: o udp: Create UDP control socket. In this mode RTPProxy will listen on UDP for control messages from SER/nathelper. Example: -s udp:127.0.0.1:9000 IP address can be '*' in which case rtpproxy will listen on all local interfaces. If omitted port 22222 is used. Note RTPProxy control protocol has no built-in security mechanisms. Make sure that you protect the listening IP and port properly when using RTPProxy with UDP control socket. o udp6: Create IPv6 UDP control socket. In this mode RTPProxy will listen on UDP/IPv6 for control messages from SER/nathelper. Example: -s udp6:::1:9000 o unix: Create UNIX domain socket for control interface. In this mode SER/nathelper and RTPProxy must be running on the same host. This is the default setting for both SER/nathelper and rtpproxy. Example: -s unix:/var/run/rtpproxy.sock Default value is /var/run/rtpproxy.sock. -t tos Set this ToS (Type of Service) in outgoing packets. Default value is 0xB8. -r rec_dir Directory where recorded RTP sessions will be stored. -S spool_dir Spool directory for RTP sessions being recorded. The file will be moved to directory configured in -r option after the session finishes. -R Do not record RTCP when recording an RTP session. This option is disabled (rtpproxy will record RTCP) by default. -p pid_file This parameter configures the name of the file where PID of running rtpproxy will be stored. Default is /var/run/rtpproxy.pid. -T max_ttl Limit the maximum TTL (Time To Live) of outgoing IP packets to the value of max_ttl. HOWITWORKS
When SER receives an INVITE request, it extracts Call-ID from it and communicates it to rtpproxy via Unix domain socket or UDP. Rtproxy looks for an existing session with such Call-ID. If the session exists it returns UDP port for that session, if not, then it creates a new session, binds to a first empty UDP port from the range specified at the compile time and returns number of that port to a SER. After receiving reply from the proxy, SER replaces media ip:port in the SDP to point to the proxy and forwards request as usually. When SER receives a non-negative SIP reply with SDP it again extracts Call-ID from it and communicates it to the proxy. In this case the proxy does not allocate a new session if it doesn't exist, but simply performs a lookup among existing sessions and returns either a port number if the session is found, or error code indicating that there is no session with such id. After receiving positive reply from the proxy, SER replaces media ip:port in the SIP reply to point to the proxy and forwards reply as usually. After the session has been created, the proxy listens on the port it has allocated for that session and waits for receiving at least one UDP packet from each of two parties participating in the call. Once such packet is received, the proxy fills one of two ip:port structures associated with each call with source ip:port of that packet. When both structures are filled in, the proxy starts relaying UDP packets between parties. The proxy tracks idle time for each of existing sessions (i.e. the time within which there were no packets relayed), and automatically cleans up a sessions whose idle times exceed the value specified at compile time (60 seconds by default). FILES
/usr/sbin/rtpproxy LICENSE
This program is licensed under the BSD license. See COPYING file in the rtpproxy sources for details. AVAILABILITY
The latest version of this program can be found at http://ftp.iptel.org/pub/rtpproxy. SEEALSO
ser(8). AUTHOR
Maxim Sobolev Author. COPYRIGHT
Copyright (C) 2006 janakj [FIXME: source] Feb 20, 2006 RTPPROXY(8)
All times are GMT -4. The time now is 01:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy