09-22-2003
AWK embeded PERL
Hello Guys,
I am refering to this great forum once again for help.
After various attempts at this, I am still failing to obtain the desire effect.
I have to write a perl script which:
1- reads two values from the user (e.g name & passwd)
2- check each value against a file containing the authentic values
3- redirect the user according to his credentials, e.g
if this user is correctly identified (and granted he/she matches
another criteria), he is then directed to a page that only his
criteria allows him/her.
else (ie credentials incorrect)
user is directed to some error page.
-----------------------------------------------------------------------------
So far I was able to:
open a file in perl
read the content of the file
read the two values ok
however, I don't know how to "awk" each field of the credential file so that I can put each entry inside a separate perl variable, and then check them against the user's ones.
the awk command I am trying to emulate is:
awk -F: '{print $x}' myfile
then I wish to send the content of $x into a perl variable :-(
N.B I realise that this forum is not meant to write me an entire program, and indeed I do not want that, since I actually want to learn how to do this. However I do welcome any help in this direction.
Thanks in advance
Da Bionic one !
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
How to embeded programme within perl programme.
Shankarao (2 Replies)
Discussion started by: shankarao
2 Replies
2. Shell Programming and Scripting
Hi all,
I'm trying to define an alias with an embeded awk command:
alias kpipe='kill `psme| grep "ifw -r" | grep -v "grep ifw -r"| awk '{print $2}'`'
The problem is that the awk command (awk '{print $2}') contains two ' ..' quotes. So bash assumes that the first awk quote corresponds to... (5 Replies)
Discussion started by: jfortes
5 Replies
3. Shell Programming and Scripting
$ echo $(tty|sed 's#/*/##')
pts/0
$ who | grep $(tty|sed 's#/*/##')
grep: 0652-033 Cannot open 0551-011.
grep: 0652-033 Cannot open Standard.
grep: 0652-033 Cannot open input.
grep: 0652-033 Cannot open is.
grep: 0652-033 Cannot open not.
grep: 0652-033 Cannot open a.
grep: 0652-033 Cannot... (2 Replies)
Discussion started by: wrl
2 Replies
4. Shell Programming and Scripting
hi all
I am new to awk/perl I would appreciate it if you could help!
how do I read a sub folder and their files.
e.g. simulation/10ms/router1.dat, router2.dat,..., router16.dat
simulation/100ms/router1.dat, router2.dat,..., router16.dat
simulation/300ms/router1.dat,... (14 Replies)
Discussion started by: mmoses
14 Replies
5. Shell Programming and Scripting
I have a script to get server information i wrote in perl because i would like to learn it (and I use it for work). It works great, however i would like to know if there is a good way to reduce the following line.
Sean (6 Replies)
Discussion started by: insania
6 Replies
6. Shell Programming and Scripting
awk -F "|" '{print $2$3$4 upto $30}' file1 > file2
Same logic, i want to write it in perl
I tried
#!/bin/usr/perl
my $line;
open FH, "<file1" or die " Can't open file $!";
open FH1, ">file2" or die "Can't open file ";
while (<FH1>){
$line = (split /\|/,$_);
print FH2 $line;... (3 Replies)
Discussion started by: pritish.sas
3 Replies
7. Shell Programming and Scripting
DEAR ALL,
i am using following command to fetch some records from more then 50000 files... command is taking more time ....
can i have perl command for the same...( i am New to perl )
awk -F "|" '{ if($4==3244898 && $5==5000185) print $66}' *.DATA (2 Replies)
Discussion started by: arvindng
2 Replies
8. Programming
hi
i have an error in script language when run it
i use python 2.4, CentOS 5.5, Qt C++ 2010/04
the error is
SystemError: null argument to internal routine
the Python Code
def main(i):
print i
if __name__ == "__main__":
main(i)
the C++ Code
PyObject *objModule =... (0 Replies)
Discussion started by: HanyM.Magdy
0 Replies
9. Shell Programming and Scripting
Hello,
I know this is a situation about the single quote and double literal, but I could not figure out after many search.
I need to loop through thousands of different BACs sequencing to optimize kmer individually.
IN=/PATH/TO/INPUT/FILES
for sample in S{01..1096}
do
run_program... (9 Replies)
Discussion started by: yifangt
9 Replies
10. UNIX for Beginners Questions & Answers
Hello. I'm currently teaching myself Perl and was trying to turn an awk code that I had written into Perl. I have gotten stuck on a particular part and a2p has not helped me at all. The task was to take a .csv file containing a name, assignment type, score and points possible and compute it into a... (1 Reply)
Discussion started by: Eric7giants
1 Replies
LEARN ABOUT ULTRIX
re_exec
regex(3) Library Functions Manual regex(3)
Name
re_comp, re_exec - regular expression handler
Syntax
char *re_comp(s)
char *s;
re_exec(s)
char *s;
Description
The subroutine compiles a string into an internal form suitable for pattern matching. The subroutine checks the argument string against
the last string passed to
The subroutine returns 0 if the string s was compiled successfully; otherwise a string containing an error message is returned. If is
passed 0 or a null string, it returns without changing the currently compiled regular expression.
The subroutine returns 1 if the string s matches the last compiled regular expression, 0 if the string s failed to match the last compiled
regular expression, and -1 if the compiled regular expression was invalid (indicating an internal error).
The strings passed to both and may have trailing or embedded newline characters; they are terminated by nulls. The regular expressions
recognized are described in the manual entry for given the above difference.
Diagnostics
The subroutine returns -1 for an internal error.
The subroutine returns one of the following strings if an error occurs:
No previous regular expression
Regular expression too long
unmatched (
missing ]
too many () pairs
unmatched )
See Also
ed(1), ex(1), egrep(1), fgrep(1), grep(1)
regex(3)