Sponsored Content
Top Forums Shell Programming and Scripting Need help in finding and replacing port numbers. Post 302241974 by ghostdog74 on Tuesday 30th of September 2008 09:06:50 PM
Old 09-30-2008
if you have Python
Code:
import os,glob,re,fileinput
pat=re.compile("port=\"(.*?)\"")
directory="/home/yhlee/test/"
for files in glob.glob(directory+"/file"):
    for lines in fileinput.FileInput(files,inplace=1):
        lines = lines.strip()
        if "EndPoint" in lines and pat.search(lines):
            port=int(pat.findall(lines)[0]) + 200
            print pat.sub("port=\""+str(port)+"\"",lines)            
        else:
            print lines


Last edited by ghostdog74; 09-30-2008 at 10:12 PM..
 

10 More Discussions You Might Find Interesting

1. IP Networking

finding port numbers

hither! whatz the command to find which process is using a specific port number? for example, port 8082? (3 Replies)
Discussion started by: darkcastle
3 Replies

2. UNIX for Dummies Questions & Answers

shellscript for finding and replacing in DG-UNIX

Newby here..... Is there any way of doing a find & replace within a huge file other than using something like : " vi - FileForReplacing < /u1/excel/consultants " contents of consultants file looks like :1,$s/0000031/CON/g :1,$s/0001032/JONES/g :1,$s/0001355/SMITH/g... (3 Replies)
Discussion started by: Gerry405
3 Replies

3. Shell Programming and Scripting

replacing numbers greater than 0 with 1

I have some ASCII files containing numerous numbers. What I'd like to do is replace all numbers greater than 0 with 1. Examples of the numbers include: - 000011 and 000042 Thanks (4 Replies)
Discussion started by: vrms
4 Replies

4. Solaris

Finding port number !!

Hi all , I want know the port no on which a particular application is running. How to find that? Thanks in anticipation (11 Replies)
Discussion started by: kumarmani
11 Replies

5. Shell Programming and Scripting

Replacing Port number Using Sed

Hi Im trying to replace http port value.However for some reason its not working.Can you guys take a look and hit me with suggestions please.Your help is much appreciated. echo "Enter Value" read ans sed -i "s/http-port = 80 /http-port = $ans/g" demo Note:demo is the filename ... (6 Replies)
Discussion started by: coolkid
6 Replies

6. Shell Programming and Scripting

Replacing numbers in bash scripts

Hi, I have lines in some files that look exactly as below, and the line numbers they occur in are always the same. (Lines 136-139) W 0.00000000 0.00000000 2.00000000 W 0.50000000 0.50000000 2.50000000 W 0.00000000 0.00000000 3.00000000 W 0.50000000 0.50000000 3.50000000 I'd like to... (0 Replies)
Discussion started by: bluesmodular
0 Replies

7. Shell Programming and Scripting

Finding and replacing links

Hi, I would like to do a scripting for finding the links based on the name I have and replace the links with the new name. General find command lists everything for that links ( means all the sub-sirs and all the files), i need only the main link and replace. Can you anyone give me some... (1 Reply)
Discussion started by: rrb2009
1 Replies

8. Shell Programming and Scripting

Mapping and replacing numbers in two files

hi i have two files one of the form 1 2 2 45 3 56 4 98 5 6598 6 98 7 10 8 0 9 15 10 56 This file's significance is that it maps the number in first column to that of the number in second column The other file is of the form 1 2 (1 Reply)
Discussion started by: vaibhavkorde
1 Replies

9. Shell Programming and Scripting

SFTP - using port numbers?

Hi Guys, I saw this line of code in a script sftp username@hostname#2200 get file and the script never asked for password. Can you please explain on this?:confused: (9 Replies)
Discussion started by: PikK45
9 Replies

10. Shell Programming and Scripting

Replacing a character between two numbers

Hi, I need to replace a character between two numbers (specifically a - to a _). The problem is that they can be *any* numbers. So, I need a one liner to turn a file like this: 1-2 3-4 55-66 4323-12312893 into the following 1_2 3_4 55_66 4323_12312893 Any help would be appreciated! (5 Replies)
Discussion started by: mikey11415
5 Replies
IEEE1284_DATA(3)						     Functions							  IEEE1284_DATA(3)

NAME
ieee1284_read_data, ieee1284_write_data, ieee1284_data_dir, ieee1284_wait_data - control the data lines SYNOPSIS
#include <ieee1284.h> int ieee1284_read_data(struct parport *port); void ieee1284_write_data(struct parport *port, unsigned char dt); int ieee1284_data_dir(struct parport *port, int reverse); int ieee1284_wait_data(struct parport *port, unsigned char mask, unsigned char val, struct timeval *timeout); DESCRIPTION
These functions manipulate the data lines of the parallel port associated with port (which must have been claimed using ieee1284_claim(3)). The lines are represented by an 8-bit number (one line per bit) and a direction. The data lines are driven as a group; they may be all host-driven (forward direction) or not (reverse direction). When the peripheral is driving them the host must not. For ieee1284_data_dir the reverse parameter should be zero to turn the data line drivers on and non-zero to turn them off. Some port types may be unable to switch off the data line drivers. Setting the data lines may have side effects on some port types (for example, some Amiga ports pulse nStrobe). ieee1284_wait_data waits, up until the timeout, for the data bits specified in mask to have the corresponding values in val. RETURN VALUE
ieee1284_read_data returns the 8-bit number representing the data lines unless it is not possible to return such a value with this port type, in which case it returns an error code. Possible error codes: E1284_NOTAVAIL Bi-directional data lines are not available on this system. E1284_INVALIDPORT The port parameter is invalid (perhaps it has not been claimed, for instance). E1284_SYS There was an error at the operating system level, and errno has been set accordingly. E1284_TIMEDOUT The timeout has elapsed. Whereas ieee1284_read_data may return E1284_NOTAVAIL on its first invocation on the port, if it does not do so then it cannot until ieee1284_close is called for that port. AUTHOR
Tim Waugh <twaugh@redhat.com> Author. COPYRIGHT
Copyright (C) 2001-2003 Tim Waugh 09/18/2007 IEEE1284_DATA(3)
All times are GMT -4. The time now is 04:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy