- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Scripting clarification
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
Discussions
Discussions
Forums
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
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
тАО04-03-2009 12:41 AM
тАО04-03-2009 12:41 AM
Re: Scripting clarification
As you said i have edit as below, i am getting output as well. But if i edit script1 without the word "Yes". Its provide me the same output.
# pg script1
#!/usr/bin/sh
server1
server2
server3
server4
server5
server6
(EOF):
--------------------------------------------
# pg script2
#!/usr/bin/sh
#ans='sed -n'5,5p'script1'
if test 'cat /script1'NR==5{print$0}="Yes"
then
echo "Your current Location"
pwd
date
else
echo "stop"
fi
(EOF):
--------------------------------------------
OUTPUT:
-------
# ./script2
Your current Location
/
Fri Apr 3 14:15:22 IST 2009
-------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 12:56 AM
тАО04-03-2009 12:56 AM
Re: Scripting clarification
Please check the quote before cat and after $0}
These quotes are command substitution quotes and not normal single quote.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 01:01 AM
тАО04-03-2009 01:01 AM
Re: Scripting clarification
if test `cat /script1 |awk 'NR==5 {print$0}'` = "Yes"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 01:06 AM
тАО04-03-2009 01:06 AM
Re: Scripting clarification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 01:15 AM
тАО04-03-2009 01:15 AM
Re: Scripting clarification
Problem fixed because of you, Thanks a ton its working fine !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 01:16 AM
тАО04-03-2009 01:16 AM
Re: Scripting clarification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 01:25 AM
тАО04-03-2009 01:25 AM
Re: Scripting clarification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 01:29 AM
тАО04-03-2009 01:29 AM
Re: Scripting clarification
This says the word "[sed" is not found. You seem to have some missing spaces.
ans='sed -n'5,5p'script1'
if [$ans=="Yes"]
The first problem is the attempted use (as TG said) of archaic ``, instead of the easy to read $()
ans=$(sed -n '5,5p' script1)
Then you are missing that space (as TG said):
if [ "$ans" = "Yes" ]; then
# pg script1
#!/usr/bin/sh
This isn't a script, it is a data file.
>TG: if test `cat /script1 |awk 'NR==5 {print$0}'` = "Yes"
No need for evil cat or test, or ``:
if [ "$(awk 'NR==5 {print $0; exit}' script1)" = "Yes" ]; then
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 01:31 AM
тАО04-03-2009 01:31 AM
Re: Scripting clarification
- « Previous
-
- 1
- 2
- Next »