- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- want to assign dirname to variable... HP UX 11.23
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
тАО07-09-2008 08:28 PM
тАО07-09-2008 08:28 PM
I've got some scripts provided by a consultant which are not working, some investigation reveals that the scripts are trying to assign the values of:
dirname
basename
to variables...but it's not working :(
Here's a small test script i made.
#!/bin/ksh
#test.sh
dbdir='dirname $1'
echo $dbdir
I pass the name of a file and i get this ...
# dirname $1
For some reason 'dirname $1' is not working and being treated as a literal.. yet every example I see of 'ksh' has this working.
Running HP UX 11.23 on Itanium, i've also tried this on HP UX 11.22 PA-Risc and no go there either...
Obviously I'm doing something dumb, but what??
Please help...
-John
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2008 09:10 PM
тАО07-09-2008 09:10 PM
Re: want to assign dirname to variable... HP UX 11.23
#!/usr/bin/ksh
#test.sh
dbdir='dirname $1'
echo $dbdir
Why does this not work? :(
:(
-John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2008 09:43 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2008 09:45 PM
тАО07-09-2008 09:45 PM
Re: want to assign dirname to variable... HP UX 11.23
- Tags:
- command substitution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2008 09:50 PM
тАО07-09-2008 09:50 PM
Re: want to assign dirname to variable... HP UX 11.23
Back quote is to execute shell var.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2008 10:02 PM
тАО07-09-2008 10:02 PM
Re: want to assign dirname to variable... HP UX 11.23
I had NO IDEA that was what the isse was...i've spent a 'whole day' on this damned thing, copying/pasting, retying from tutorials and so forth.
I'll now go back and look at these scripts... they were supplied in a PDF file and I copied/pasted them to notepad then put them onto the system.
I will make a note of this, to use:
` instead of '
:) Am now Happy :) Points assigned!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2008 10:23 PM
тАО07-09-2008 10:23 PM
Re: want to assign dirname to variable... HP UX 11.23
The $() convention is MUCH MUCH easier to read and will NEVER be mistaken for a single-quote.
dbdir=$(dirname $1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-10-2008 12:13 AM
тАО07-10-2008 12:13 AM
Re: want to assign dirname to variable... HP UX 11.23
thanks again everyone!
I've fixed the scripts and they work now!
Going to give that ($) a go tommorrow too
-John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-10-2008 01:40 AM
тАО07-10-2008 01:40 AM
Re: want to assign dirname to variable... HP UX 11.23
It's the best thing since sliced bread. You can nest $( ... $(...) ... )
You can throw away cat with: $(< file)
You can also get arithmetic expressions:
echo $(( 1 + 2 ))
- Tags:
- evil cat