- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Why does not work a sentece kept in a variable whe...
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-18-2006 06:07 AM
05-18-2006 06:07 AM
i have a program which has the following variable:
VALOR="/usr/bin/ftp_-v_-n_-i_<_$logftp_>_${logftp}_out"
then, this value is sent to other script named script2:
script2 $VALOR
script2 contains many things between them:
....
...
echo $2 | sed 's/_/ /g'
...
...
it guess $2 is an instruction apart of be a command ... but it does not work as command !!!
it does not make the ftp indicated in that variable ... why?
can you help me??
Thanks ...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2006 06:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2006 06:18 AM
05-18-2006 06:18 AM
Re: Why does not work a sentece kept in a variable when is delivered in other script?
You need to pipe the output of sed to the shell in order for the command to be executed i.e.
replace...
echo $2 | sed 's/_/ /g'
with...
echo $2 | sed 's/_/ /g' | sh
Only then the ftp will be executed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2006 06:38 AM
05-18-2006 06:38 AM
Re: Why does not work a sentece kept in a variable when is delivered in other script?
You don't need to perform the contortions of embedding underscore characters that you change to spaces. Consider:
# logftp="xxxxxx"
# VALOR="/usr/bin/ftp -v -n -i < ${logftp} > ${logftp}_out"
# ./showme DOTHISFORME "${VALOR}"
If ./showme looks like this below, then the second argument received is your ${VALOR} string and the first argument will be "DOTHISFORME":
# cat ./showme
#!/usr/bin/sh
echo $1 $2
exit 0
In 'showme' you could execute ${VALOR} by writing:
#!/usr/bin/sh
echo "I was told $1 $2"
$2
exit 0
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2006 08:13 AM
05-18-2006 08:13 AM
Re: Why does not work a sentece kept in a variable when is delivered in other script?
do not work either "${VALOR}" or "| sh" at the end of the sentence ...
i do not know why!!!??
some time i read about comand exe or exec or something like that, do you know it?
I'm using /uar/bin/sh shell
Please help !!
Thanks .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2006 08:33 AM
05-18-2006 08:33 AM
Re: Why does not work a sentece kept in a variable when is delivered in other script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2006 09:04 AM
05-18-2006 09:04 AM
Re: Why does not work a sentece kept in a variable when is delivered in other script?
OK, since you are using redirection we need to modify the wrapper I provided by adding an 'eval' statement (see the 'sh-posix(1)' manpages):
Consider again:
# logftp="xxxxxx"
# VALOR="/usr/bin/ftp -v -n -i < ${logftp} > ${logftp}_out"
# ./launch DOING "${VALOR}"
...where:
# cat ./launch
#!/usr/bin/sh
echo "$1 : $2"
eval $2 # <--- NOTE
exit 0
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2006 09:05 AM
05-18-2006 09:05 AM
Re: Why does not work a sentece kept in a variable when is delivered in other script?
if what you want to handle in your second script is
script2 param1 "/usr/bin/ftp -v -n -i < $logftp > ${logftp}_out"
i would write script1 with
VALOR="/usr/bin/ftp -v -n -i < ${logftp} > ${logftp}_out"
script2 param1 "${VALOR}"
and then in script2:
# retrieve first param
param1=$1
# retrieve rest of command line.
shift
param2=$*
hope this helps.
antonio.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2006 09:42 AM
05-18-2006 09:42 AM
Re: Why does not work a sentece kept in a variable when is delivered in other script?
What is stored inside "logftp" variable. Not sure if the hostname you're trying to ftp to is contained in $logftp. Anyway post the output of the following:
# echo $VALOR
# echo $logftp
thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2006 08:55 PM
05-18-2006 08:55 PM
Re: Why does not work a sentece kept in a variable when is delivered in other script?
in VALOR, change the underscores in blanks
Then the line in script2 should read:
echo $*|sh
If you like to keep the underscores, you have to write it like ...<_${logftp}_>_${logftp}_out
because _$ seems to be something special for the shell and it 'eats' your variable.
In script2, then you should use:
echo $*|sed 's/_/ /g'|sh
Greetings,
Philippe