- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: echo command
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
05-28-2007 05:30 PM
05-28-2007 05:30 PM
echo command
I have this script test.sh as below:
for x in "${*}"
do
echo $x > /tmp/rub.log
done
But the problem is is if I do below :
./test.sh `pwd`
when I do :
#more /tmp/rub.log
/tmp
What i intend to do is so that even if I put in
#./test.sh `pwd`
#more /tmp/rub.log
`pwd`
any help please
Regards
mB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2007 06:05 PM
05-28-2007 06:05 PM
Re: echo command
`pwd`
into:
/tmp
(or whatever it is), so your script sees
only:
/tmp
(or whatever), not:
`pwd`
.
You could use apostrophes to quote the thing:
./test.sh '`pwd`'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2007 06:23 PM
05-28-2007 06:23 PM
Re: echo command
But the problem is i cannot control the user input ..
So we might have user doing ./test.sh `rm -rf *` and it will damage the system.
We are trying to play around with the script whether we can avoid this.
Any idea how ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2007 06:25 PM
05-28-2007 06:25 PM
Re: echo command
The other way would be to Escape the special characters instead of putting them in quotes.
So it would read
#./test.sh \`pwd\`
The problem with quoting is that shells evaluate single quotes(') and double quotes (") differently and this can be confusing especially to shell script novices.
HTH
Andrew Y
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2007 06:40 PM
05-28-2007 06:40 PM
Re: echo command
> `rm -rf *` and it will damage the system.
If the user can damage the system that way,
then why couldn't he do it more easily by
just saying:
rm -rf *
?
Why would he need your script to cause
trouble?
> We are trying to play around with the
> script whether we can avoid this.
Good luck. As I said, your script never
sees:
`pwd`
or:
`rm -rf *`
The shell evaluates those expressions before
it passes the output to your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2007 07:35 PM
05-28-2007 07:35 PM
Re: echo command
It is the same as ${*}. If you want each quoted you must use: "${@}"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2007 12:47 AM
05-30-2007 12:47 AM
Re: echo command
There is the restricted shell (rsh) that prevents certain kinds of command execution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2007 09:00 AM
06-01-2007 09:00 AM
Re: echo command
case ${RSH_CMD} in
rm)
echo "No way, Jose."
;;
ls)
/usr/bin/ls
;;
mv)
if [ "${USERNAME}" = "Tony" ]; then
/usr/bin/mv
else
echo "No way, Jose."
fi
;;
*)
echo "Not a supported command."
;;
esac
Anyway, you get the idea.