- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: help with script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2001 08:22 AM
09-24-2001 08:22 AM
This is just part of my script that I am working on right now. The issue here is when I ran this script, I am not getting what I'm asking for but this is somehow showing me a listing of everything in my directory. Can you please tell me what I could be doing wrong here. Let me know if you need additional info.
Get the start time
ssh $i "tail /var/opt/ignite/logs/makrec.log1 2> /dev/null | grep 'Started' | tail -1" > $TMP_PAGE2
echo "
" >> $TMP_PAGE2
echo $END
# Get the end time - will also use later for COLOR selection
END=$(ssh $i "tail -2 /var/opt/ignite/logs/makrec.log1 2> /dev/null | grep -v -e 'Completed' -e 'makrec.log1'")
echo $END
echo "
" >> $TMP_PAGE2
echo "" >> $TMP_PAGE2
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2001 08:29 AM
09-24-2001 08:29 AM
SolutionI couldn't quite understand this line
END=$(ssh $i "tail -2 /var/opt/ignite/logs/makrec.log1 2> /dev/null | grep -v -e 'Completed' -e 'makrec.log1'")
Shouldn't it be
END=`ssh $i "tail.... " `
check the command substituation quotes "`".
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2001 08:39 AM
09-24-2001 08:39 AM
Re: help with script
I believe you want 'grep -i' and *not* 'grep -v' in your construction of the 'END' variable.
BTW, Srhhdar, the syntax is POSIX's which is "preferred" over the tick yntax.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2001 08:59 AM
09-24-2001 08:59 AM
Re: help with script
If you are looking for the completion time, you could do something like,
END=$(ssh $i "tail -2 /var/opt/ignite/logs/makrec.log1 2> /dev/null | grep '^Completed'")
Also in your first ssh line where you are redirecting the output to $TMP_PAGE2, you might want to use something like
ssh $i "grep 'Started' /var/opt/ignite/logs/makrec.log1 2> /dev/null | tail -1" > $TMP_PAGE2
(tail by default only shows the last 10 lines)
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2001 10:56 AM
09-24-2001 10:56 AM
Re: help with script
Yes. You need to replace -v with -i.
The reason why you were getting the output of ls is because, your remsh command with grep -v would assign the string ***** to your variable 'END'.. So when you echo $END = $***** which is equivalent to echo *, you will get the file listing.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2001 12:43 AM
09-25-2001 12:43 AM
Re: help with script
just a tiny hint, probably nothing to do with your problem.
When invoking a remote shell (applies to remsh as well as ssh) you need not quote the remote command because everything after the remote hostname is treated as a remote command and its arguments.
But you do have to be careful with any shell meta characters (such as your redirection of stderr).
If such meta characters in the remote command string aren't escaped they will be expanded by your local shell (from where you issue ssh).
This means that if you want to append other commands, or pipe into other commands, or execute a subshell etc on the remote system you have to prepend a '\' to every [|;&<>()].