Search Results

Search: Posts Made By: Klashxx
2,332
Posted By Klashxx
Using GNU date: $ date --date="Dec 11"...
Using GNU date:
$ date --date="Dec 11" +"%Y-%m-%d"
2014-12-11
3,923
Posted By Klashxx
Try this: #!/bin/bash typeset -i interval=5 ...
Try this:
#!/bin/bash
typeset -i interval=5
run=true
trunk=vonage
reboot=0
while [[ "$run" == "true" ]]; do
checktrunk=$(asterisk -rx "sip show peer $trunk" | grep -c "Status.*OK")
if...
4,747
Posted By Klashxx
Nice & clean @Yoda , just one point i .. i would...
Nice & clean @Yoda , just one point i .. i would use next to avoid the second matching this way:
awk '
/>/ {
$0 = ( NR == 1 ? $0 : RS $0 RS )
print
...
3,224
Posted By Klashxx
Add tou your ssh: -o ConnectTimeout=n Where n...
Add tou your ssh:
-o ConnectTimeout=n
Where n is compute as seconds.
17,586
Posted By Klashxx
Hi @wisecracker, i just wanted tho show a...
Hi @wisecracker, i just wanted tho show a practical usage of look-ahead/behid assertion, for me the important thing here is not the print statement and of course i can't guarantee python in all *nix...
1,353
Posted By Klashxx
I would choose another python approach by using...
I would choose another python approach by using datetime calculation facilities:
#cat filter.py
#!/usr/bin/python

import sys
import datetime

first_offline = {}
with open(sys.argv[1],'r')...
2,261
Posted By Klashxx
python shell: >>> import re >>> text = ''' ...
python shell:
>>> import re
>>> text = '''
... Server Stopped
... ABC
... DEF
... GHI
... JKL
... Server Started
... MNO
... PQR
... STU
... Server Stopped
... VWX
... YZ
... ABC
......
6,199
Posted By Klashxx
Try this logic: #!/usr/bin/python import...
Try this logic:
#!/usr/bin/python

import re
import ping, socket
import subprocess
from subprocess import Popen, PIPE

pattern = re.compile(r'inet.\S+(\S+\d+\.\d+\.\d+\.)')

p1 =...
4,139
Posted By Klashxx
Try: sort -un inputfile
Try:
sort -un inputfile
1,753
Posted By Klashxx
Quick dirty awk: awk...
Quick dirty awk:
awk 'NR==1{L=$NF<$(NF-1)?$NF:$(NF-1)}$(NF-1)<= L{L=$(NF-1);t=$0};$NF<=L{L=$NF;t=$0}END{print t}' infile
9,090
Posted By Klashxx
You should pick one tool and keep stick to it. ...
You should pick one tool and keep stick to it.
A starting point to give python a try:
#!/usr/bin/env python
import re
import sys

pattern = re.compile(r'''
...
9,090
Posted By Klashxx
Interesting regex (python shell again): >>>...
Interesting regex (python shell again):
>>> text = '''
... @LIB ADVAPI32.dll @CAL RtlInitAnsiString @PA1 0x0012f740 @PA2 "CriticalSectionTimeout" @RET0
... @LIB ADVAPI32.dll @CAL...
9,090
Posted By Klashxx
From python shell: >>> import re >>> text =...
From python shell:
>>> import re
>>> text = '''
... @LIB ADVAPI32.dll @CAL RtlInitAnsiString @PA1 0x0012f740 @PA2 "CriticalSectionTimeout" @RET0
... @LIB ADVAPI32.dll @CAL memmove @PA1...
1,174
Posted By Klashxx
Not sure if i understood correctly, but this may...
Not sure if i understood correctly, but this may helps:
# awk '{a[$NF]=sprintf("%s%s ",a[$NF],$1)}END{for (i in a){print i,a[i]}}' infile
1.1.1.1 app1 app3
1.1.1.2 app2
1.1.1.3 app4
5,873
Posted By Klashxx
Give this a try: awk '/<\/RECORD/{ ...
Give this a try:
awk '/<\/RECORD/{
print raw""$0 > name".xml"
name=""
raw=""
next}
...
1,382
Posted By Klashxx
Another way: ls *_2010*| sed -e...
Another way:
ls *_2010*| sed -e "p;s/_2010/_2014/"|xargs -n2 mv
1,713
Posted By Klashxx
In a oneliner: perl -ne 's/(\s*|\n)//g;print...
In a oneliner:
perl -ne 's/(\s*|\n)//g;print $_' inputfile
Inside a multiline script:
perl -e 's/(\s*|\n)//g && print $_ foreach (<>);' < inputfile
5,820
Posted By Klashxx
ok , use: file_avail=`ssh username@host 'if [[...
ok , use:
file_avail=`ssh username@host 'if [[ -f "directory/structure/Daily Report.xls" ]]; then echo 1; else echo 0; fi'`
Personally , i prefer:
ssh username@host 'if [[ -f "Daily Report.xls"...
2,839
Posted By Klashxx
Python re module maybe handy for that task: ...
Python re module maybe handy for that task:
echo "abcd fkaj&dsdsd;"|python -c 'import re;import sys;print re.escape(sys.stdin.read().strip()),'
5,128
Posted By Klashxx
As simply as: s= int(line[1])-1 In your...
As simply as:
s= int(line[1])-1
In your original script.
2,774
Posted By Klashxx
Try with this less verbose example: ...
Try with this less verbose example:
#!/usr/bin/env python
import sys
from decimal import Decimal
with open(sys.argv[1],'rb') as f:
for number in f:print str(Decimal(number))
About Python...
7,426
Posted By Klashxx
Interactive menu
Hi ,some time ago i did an interactive menu based on eval function for navigation , one of the post remind me it. I think it could be handy for others.

#!/usr/bin/ksh

keyRead ()
{
tput smso...
8,663
Posted By Klashxx
Try: scp -B -p...
Try:
scp -B -p ${Auser}@${aSrcHOST}:${aSrcDIR}/*.[Oo][Kk] $aTgtDIR
1,013
Posted By Klashxx
If perl is ok: perl -lane 'if...
If perl is ok:
perl -lane 'if (/Name:\s+(\S+)/){$group=$1};if(/^\s*(\d+)\s+(\S+)\s+(\S+)/i && $group){print $2.",".$3.",".$1.",".$group}' infile
2,971
Posted By Klashxx
Or: if [ "$ServerName" = "usei01" -o...
Or:
if [ "$ServerName" = "usei01" -o "$ServerName" = "usei02" -o "$ServerName" = "usei03" ]
Showing results 1 to 25 of 106

 
All times are GMT -4. The time now is 06:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy