Can't find string terminator "`" anywhere before EOF


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can't find string terminator "`" anywhere before EOF
# 1  
Old 10-07-2014
Can't find string terminator "`" anywhere before EOF

// AIX 6.1

What I am trying to accomplish is to display the user name and the last login date and time in one line:

Code:
for usrlist in $(cat  alluser.txt)
do
$usrlist 
perl -e 'print scalar localtime `lsuser -a time_last_login $usrlist | awk -F '=' '{print $2}'`' 
done

However, it seems this line (tested with jdoe user account)
Code:
perl -e 'print scalar localtime `lsuser -a time_last_login jdoe | awk -F '=' '{print $2}'`'

returns an error saying
Code:
Can't find string terminator "`" anywhere before EOF

.

Can you please let me know how to resolve this error and display the user name and the converted time_last_login next each on one row?

Appreciate it!

Last edited by vbe; 10-07-2014 at 04:49 PM..
# 2  
Old 10-07-2014
Hi,
Your problem is with mutiple quote ('),so:
Code:
perl -e "print scalar localtime \`lsuser -a time_last_login jdoe | awk -F '=' '{print $2}'\`"

should work...

Regards.
# 3  
Old 10-07-2014
Quote:
Originally Posted by disedorgue
Hi,
Your problem is with mutiple quote ('),so:
Code:
perl -e "print scalar localtime \`lsuser -a time_last_login jdoe | awk -F '=' '{print $2}'\`"

should work...

Regards.
Thank you!! Is it possible that we can display the username and time on one row so that I can have a better output?

right now, I am getting like:

HTML Code:
Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31 19:00:00 1969Wed Dec 31
# 4  
Old 10-07-2014
Perl does not require the help of awk, what's the output of lsuser -a time_last_login jdoe?
# 5  
Old 10-07-2014
Quote:
Originally Posted by Aia
Perl does not require the help of awk, what's the output of lsuser -a time_last_login jdoe?
It shows:
HTML Code:
jdoe time_last_login=1412251621
What I want is as the output is:

HTML Code:
jdoe  Wed Dec 31 19:00:00 
.....
or even better

HTML Code:
jdoe   12/31/2013 19:00:00
....
Please advise.
# 6  
Old 10-07-2014
As "Aia" noted you can do all your processing in perl instead of mixing shell / perl / awk into a single code snippet...
# 7  
Old 10-07-2014
I would do it in two statements
Code:
last=`lsuser -a time_last_login jdoe | awk -F '=' '{print $2}'`
perl -le "print scalar localtime $last"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find . -path "*_nobackup*" -prune -iname "*.PDF" \( ! -name "*_nobackup.*" \)

These three finds worked as expected: $ find . -iname "*.PDF" $ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \) $ find . -path "*_nobackup*" -prune -iname "*.PDF" They all returned the match: ./folder/file.pdf :b: This find returned no matches: $ find . -path "*_nobackup*" -prune... (3 Replies)
Discussion started by: wolfv
3 Replies

2. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

3. UNIX for Dummies Questions & Answers

Find a string across line break (because of "segmentation fault core dumped")

Hi, thanks to a precedent post, and thanks to the reply of derekludwig of the forum, I have convert my first awk command as : test.txt is : AAAAAGHIJKLAjKMEFJKLjklABCDJkLEFGHIJKL awk -f findstring.awk test.txt > textreturn.txtfindstring.awk is : BEGIN{ SLENGTH = 3 } { ... (3 Replies)
Discussion started by: thewizarde6
3 Replies

4. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

5. Shell Programming and Scripting

grep with "[" and "]" and "dot" within the search string

Hello. Following recommendations for one of my threads, this is working perfectly : #!/bin/bash CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" ) Now I need a grep success for some thing like : #!/bin/bash CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies

6. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

7. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

8. Shell Programming and Scripting

input string="3MMTQSZ348GGMZRQWMJM4SD6M";output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6

input string="3MMTQSZ348GGMZRQWMJM4SD6M" output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6M" using linux shell script (4 Replies)
Discussion started by: pankajd
4 Replies

9. Shell Programming and Scripting

"find command" to find the files in the current directories but not in the "subdir"

Dear friends, please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories.. it is like this, current directory contains file1, file2, file3, dir1, dir2 and dir1 conatins file4, file5 and dir2 contains file6,... (9 Replies)
Discussion started by: swamymns
9 Replies

10. Shell Programming and Scripting

"unexpected end of file" when Iīm use EOF inside block if

I have a trouble in my script when i use EOF inside block if. If i use EOF whitout block if I donīt have problem. Guys any ideas? Sorry for my terrible English. #!/bin/sh set -xv HOST='ftp.fiction.com.br' USER='fictionuser' PASS='fictionpass' FILE='ftpteste.txt' busca=`find... (4 Replies)
Discussion started by: ricardo.ludwig
4 Replies
Login or Register to Ask a Question