Programming :: Awk Computed Regex Not Working As Expected
May 31, 2011
So those of you that know me will agree that when it comes to awk I don't usually ask a lot of questions ... however this one has me stumped. I am guessing I have missed something obvious but for the life of me (and I have tested at great length) I cannot find it So the scenario is this: The following awk code should identify all versions of libgpg-error within the attached file (see below) and only show one for each version:
[Code]...
View 12 Replies
ADVERTISEMENT
May 14, 2011
I need a regex expression to read IP address from lines like these for my perl script:
Code:
2011.05.13-14:54:58, test@xyz.com, 180.211.51.11, pop3
2011.05.13-14:57:26, test@xyz.com, 160.234.47.12, pop3
2011.05.13-14:57:54, www@abcd.com, 166.22.22.224, imap
2011.05.13-14:57:55, www@somedomain.com, 172.58.22.154, imap
2011.05.13-15:03:08, www@example.com, 190.22.120.44, pop3
View 6 Replies
View Related
Jan 13, 2011
In a bash-script, only the case if a regular expression does not match is relevant.herefore I used the exclamation mark !. But where to place it?
These two work fine, but are they equivalent?
Code: if ! [[ $abc =~ $pattern ]]; then or
Code: if [[ ! $abc =~ $pattern ]]; then Where is the ! placed more correct?
View 2 Replies
View Related
Jun 1, 2011
I'm just starting out with bash scripting (yesterday, really). I want to add a file to each user's home directory, pretty simple really, and send it out via our Apple Remote Desktop system to our Macs. Here is my script: Code: #!/bin/bash
for i in $(ls -d /Users/*)
doif [ -e $i/.tcshrc ]
thenecho "$i/.tcshrc exists!"elseecho "$i/.tcshrc does not exist"
[code]....
View 6 Replies
View Related
May 5, 2010
I'm using bash scripting to find any file that matches a path governed by the following regular expression:
"(monthly|nightly).[0-9]+/home/(user1|user2)/.mailbox/"
to match files like:
monthly.9/home/user1/.mailbox/l23131564
nightly.15/home/user2/.mailbox/cur/6546213
I've tried:
Code:
myRegex="(monthly|nightly).[0-9]+/home/(user1|user2)/.mailbox/"
find ./ -regextype posix-egrep -regex $myRegex
and it just spins and never gives me an answer, even though the file structure isn't that big.
View 8 Replies
View Related
Jun 4, 2010
I used setfacl to set permissions as follows:
As you can see all settings lead to permissions 777 but that's not what happens. What happens if I say, touch a file, I get: 666 as this shows:
Same for files that are not obviously scripts such as just a.txt.
My umask is 0022.
Does anyone know why this is? Is it changeable for specific directories?
This is a special world viewed directory required by a piece of software... in other words, no, I am not in a habit of setting file permissions to 777 so please no comments about you shouldn't be using such permissions.
Truthfully, I can probably get away with permissions 666 and will if I can but right now I just want to know why it's happening this way and how to control it.
View 4 Replies
View Related
Mar 24, 2010
I'm trying to test whether some software that I am using will behave as expected when DST change over occurs. I'm specifically testing it for the GB timezone when it enters British Summer Time (BST) and then reverts to GMT. From the information I have, BST starts: Sunday 28 March 01:00 GMT (02:00 BST)and ends: Sunday 31 October 02:00 BST (01:00 GMT )To do this test I wrote a shell script that sets the date, runs the program, checks some logs and then reverts the time.
Entering BST was fairly straight forward as all I had to do was the following: export TZ=GB
date 032800582010This set the date to be 28th March and the time to be 00:58 in the GB (GMT) timezone. As expected, the date then rolled forward to 02:00 BST. However, when I tried to do the same for coming out of BST into GMT, the time did not work out as expected. export TZ=GB
date 103101582010Setting the time as above put the time straight into GMT and not BST even though it was two minutes before the time should have rolled-over.
However if I put the following: export TZ=GB
date 103100582010the date was reported as BST!
How can I setup the time so that I don't have to wait for hour before BST ends?
View 2 Replies
View Related
Apr 3, 2011
I'm writing a script to read user input for a computername.I need a check that a given userinput is valid.Right now I use grep like this (for sure not optimal):Quote:
if echo "$name" | grep -q '[^a-z][^A-Z][^0-9]'; then
echo error
else
[code]....
View 12 Replies
View Related
Jun 9, 2010
the following works and BASH doesn't complain, but VIM highlights the closing square bracket is if it sees a syntax error. Is there a better way to express regex in a case statement or is this an issue with VIM?
Code:
#!/bin/bash
case $1 in
[code]...
View 3 Replies
View Related
Jun 10, 2011
Code:
g echo ${mm[$j]}
4 BashNotes
[code]...
View 2 Replies
View Related
Feb 23, 2011
I'm fairly new to Perl and regular expressions. I have a large collection of files with their file names in the following general format: string - another string with spaces (2004) [year].ext I would like to know how I could create a regex to separate out:
the first string
another string with spaces
year
extension
If you know of a better way of doing it without regular expressions, I would be happy to hear that way too.
View 13 Replies
View Related
Mar 19, 2010
I'm trying to find out how to extract the string between the 2 <title> tags: <title>this is what i want</title>.I found lots of results but nothing I've tried works.. EG:$page =~ m/<title>($.)</title>/gism;
View 2 Replies
View Related
Jan 17, 2010
I was wondering if you insert a variable into a regex in Perl, will the contents of the variable be expanded by the regex engine?
View 14 Replies
View Related
Mar 13, 2011
I have .txt.gz files that store queries made on a browser, d my job is to analyze them.The information is stored in a xml-like style.Quote:
<browser>lwp-trivial/1.41</browser>
<http_code>200</http_code>
<keywords />
[code]...
View 6 Replies
View Related
May 13, 2011
On Slackware64 13.1 the as-installed en_GB locale gave Sunday as the first day of the week. This was not an issue until Xfce's Orage calendar was used when its display of Sunday as the first day of the week was offputting for someone used to Monday. A minor inconvenience but expected to be easy to fix.
At the command line:
Code:
c@CW8:~$ export LANG=en_GB <== same for en_GB.utf8
[code]....
View 2 Replies
View Related
Jun 20, 2010
On the computer on which I have to login, Shoreline is installed.I know I can add rule to /etc/shoreline/rules but I decided to manually enter an iptable rule by typing:
Quote:
/sbin/iptables -A local2fw -s 10.100.98.74 -p tcp -m tcp --dport 22 -j ACCEPT
Then why am I not able to login using 10.100.98.74... I get connection refused error...
View 3 Replies
View Related
May 5, 2010
There is this one server running CentOS5.4 Final which has certain application like Bugzilla. I have setup ssh on it and setup is for password less authentication. Have also setup PasswordAuthentication to no. So with password authentication should succeed. But it is. Though password less authentication is working fine, but I am also able to login using password.
Code:
RSAAuthentication yes
PubkeyAuthentication yes
PermitEmptyPasswords no
PasswordAuthentication no
View 4 Replies
View Related
Jun 22, 2009
CentOS 5.2. Openldap server-2.3.27-8.el5_2.4 I'm trying to get the server to do two things. One is allow authentication--that is, if a client is configured to use openldap for authentication, it should be able to access this server.
In other words, on machine_2, a client, doing getent passwd (as a quick test) will show the users in the openldap database. The more or less out of the box configuration works for this. However, as soon as I start trying to add ACLs, it stops working. For example, I want to restrict access to an address book which is also in the database. So I have
access to base.dn(changing base to subtree makes no difference) "ou=addressbook,dc=example, dc=com"
by users read by anonymous auth Now, even though this is just the address book, after that, an ldap client can no longer get the names of users in ou=People, and using the ldap server for authentication doesn't work.
I don't understand what I'm missing. ACLs are supposed to work first match wins. *IF* I add under that, access to * by * read, it will work, but the address book can then be accessed without a bind dn.
I am not sure what I'm overlooking. If I put in any sort of access control, the only way that clients can continue to use the server for authentication is adding that access to * (or to dc=example,dc=com"), by * read. I tried using access to ou=Group and ou=Peoplle by * read, thinking that would allow the clients to authenticate, but that doesn't work either, The idea is to allow any machine configured as a client to use it for authentication, but also to restrict viewing the address book only to those with a proper bind dn name.
View 4 Replies
View Related
Apr 27, 2010
I was wondering why this code only returns me the same value ten times instead of valuate the conta+0.1 value code...
View 6 Replies
View Related
Jan 9, 2010
how do you include a string variable as part of a regex in Perl?
View 5 Replies
View Related
Apr 8, 2011
I want to match for this string:
Code:
Content-Transfer-Encoding:[:space:]base64
Content-Disposition:[:space:]attachment;[:space:]filename="%variable%"
Both lines are new lines, so they won't be inline. Other than that, they are all constants, I want this regex match to be an if statement rather than returning match string. so if the $content variable contains some string that matches:
Code:
if `sed "//p"` ;
View 4 Replies
View Related
Mar 22, 2011
Im trying to extract the href of a <link> tag from a html page however as some links contain further preferences I seem to be unable to extract them, do you have any idea how I can write this: Link:
[Code]...
View 9 Replies
View Related
Nov 10, 2010
am trying to find a proper regex to match the two numbers in the following log entry.
Code:
15:08:16.142 INF Found 64468
15:08:16.142 ERR [Uniform test code=64469]
Basically the pattern I'm looking for will match the two different numbers spanned across two lines.Thought I need to use multi-line mode as follow but this doesn't match on [URL]...
Code:
/^($[0-9]{5}
[0-9]{5})$/m;
View 6 Replies
View Related
Nov 19, 2010
How do i use perl regex to extract the hostname from a FQDN?
I have
Quote:
$host=ganymede.a.linux.com
$host=io.a.linux.com
$host=europa.a.linux.com
i just want the characters which are to the left of the first .(dot) in FQDN name. I could get it using substr and split function,but how do i get it through regex.
View 13 Replies
View Related
Apr 8, 2011
I have a sed match that matches for certain string of a regex expression:
Code:
tname=$(echo "$contents" | sed -n 'some pattern')
How do I match for multiple strings in the $contents and return them as an array? for example
Code:
contents="this is a text, just to match patterns, here is another text to be matched"
the sed func would be able to recognize both "text"s, but only one is outputted?
Possible to put it in an array? so ${bar[0]} gives one and ${bar[1]} gives another
View 3 Replies
View Related
Mar 4, 2010
I want to try out the screenlet called Folder View:[URL]I have downloaded and installed it fine. However, when I double-click on it (or use the Start/Stop button) there is a momentary flash and then nothing interesting. I have checked on the widget layer and on all desktops and I have tried various settings in Options all to no avail
View 2 Replies
View Related
Nov 9, 2010
I have tried to find solution in existing posts but could not specifically find any with my kind of issues and hence a new post on oft repeated subject !! -- and apologies for a long long post here.Here is where I am ..On a AMD 64bit machine - I have ubuntu 10.10 desktop installed. I want this development machine to support virtual mailboxes so that I can use them from multiple apps and create real life deployment situations.I installed postfix + dovecot following the tutorials available here and current state is - I can send mails using telnet sessions and I see that the mail files are getting created in /Maildir form as I have directed in the conf files. I have configured Thunderbird mail client as well.
Issue #1: Mail sending works from Thunderbird but it always responds back with 'No mail on server' message when I try to receive mails. SMTP is configured with STARTTLS and POP3 with None (i.e. plain text password)Issue #2: Also, while going thru conf, logs and during testing - I found a few things which defer in this installation for authentication. I have given the session transcripts here.Issue #3: That being major issue - I also want to configure my virtual users to use TB client to access their mails - I did not find any tutorials or pointers towards that in my search for past few days. If I send mails to a non-Unix virtual user - the mail gets stored into /home/vmail/<domain>/<user>/new directory.Here are the conf files.main.cf for postfix
Code:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
[code]....
View 1 Replies
View Related
Jun 25, 2011
Y want to rename a bunch of files and directories to remove the space on the names, easy enough right?
Code:
for source in $(find ./); do target=$(echo "$source"|sed -e 's/ /_/g'); mv -f "$source" $target; done
Well, I thought that should have work but the problem is that $source comes up broken, when I run it with echo instead of mv I get the echo with broken names.
Code:
In this case "$source"="This is the file I want to rename"
$ echo "$source"
[Code]....
View 3 Replies
View Related
Mar 13, 2011
Not sure if this is the correct area to ask this question as it pertains to Upstart but not necessarily to Ubuntu.
Anyhoo, I have made a small alteration (obviously the cause of error ) but not really sure why it does not work.
rsyslog.conf:
Code:
# rsyslog - system logging daemon
#
# rsyslog is an enhanced multi-threaded replacement for the traditional
# syslog daemon, logging messages from applications
[Code].....
View 3 Replies
View Related
Feb 2, 2010
Can you tell me why gcc on LINUX is giving me this error (works find on our SCO machine)/us4/prw/include/vv_sys.h:797: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef'
797 typedef struct node_struct /*NODE STRUCTURE */
798 {
799 struct node_struct *prev_ndp; /*previous node pointer */
[code]....
View 8 Replies
View Related