HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- "echo" usage
Operating System - HP-UX
1833160
Members
3194
Online
110051
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
03-04-2002 04:55 PM
03-04-2002 04:55 PM
I am using "echo" command in my script to find out the return code.
Eg : cp -p dir1 dir2 |wc -l
echo $?
I have many cases where I need to used a pipe.
The second half after the pipe almost always succeeds, so the error code is always "0".(even if the first half fails). How I can find out if both sides of the pipe have succeeded or not ?
Thank you
Krishnan
Eg : cp -p dir1 dir2 |wc -l
echo $?
I have many cases where I need to used a pipe.
The second half after the pipe almost always succeeds, so the error code is always "0".(even if the first half fails). How I can find out if both sides of the pipe have succeeded or not ?
Thank you
Krishnan
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2002 05:02 PM
03-04-2002 05:02 PM
Re: "echo" usage
Hi,
Why not this:
#!/sbin/sh
if cp -p dir1 dir2 > /tmp/listing
then
echo "Copy is successful"
wc -l /tmp/listing
rm -f /tmp/listing
else
echo "Copy is unsuccessful"
fi
Hope this helps. Regards.
Steven Sim Kok Leong
Why not this:
#!/sbin/sh
if cp -p dir1 dir2 > /tmp/listing
then
echo "Copy is successful"
wc -l /tmp/listing
rm -f /tmp/listing
else
echo "Copy is unsuccessful"
fi
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2002 05:07 PM
03-04-2002 05:07 PM
Re: "echo" usage
Hi,
If you insist on using a pipe, then:
#!/sbin/sh
if cp -p dir1 dir2 && cp -p dir1 dir2 | wc -l
then
echo "Both copy and wordcount are successful."
else
echo "Either copy (most likely) or wordcount is unsuccessful."
fi
Hope this helps. Regards.
Steven Sim Kok Leong
If you insist on using a pipe, then:
#!/sbin/sh
if cp -p dir1 dir2 && cp -p dir1 dir2 | wc -l
then
echo "Both copy and wordcount are successful."
else
echo "Either copy (most likely) or wordcount is unsuccessful."
fi
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2002 05:31 PM
03-04-2002 05:31 PM
Solution
Hi Iyer,
Check this out:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x569d8b55dfd6d4118fef0090279cd0f9,00.html
HTH,
Shiju
Check this out:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x569d8b55dfd6d4118fef0090279cd0f9,00.html
HTH,
Shiju
Life is a promise, fulfill it!
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP