- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How can i show a variable value given in a str...
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
Forums
Discussions
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
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-14-2006 03:36 PM
05-14-2006 03:36 PM
i'm using a function wich obtains a line with information to create a file which will be used by ftp command as follows:
main script has configured the following line:
interface_name=/home/user1
functons_path=/home/user1/FUNCTIONS
fpgp2=new_file.txt
fun_sendinf_ftp $interface_name $functions_path $interface_log $fpgp2
DATOS=user=open#111.222.333.444=user#test#test=binary=prompt#off=mput#$fpgp2=dir#$fpgp2=bye
#---> This is function file:
function fun_sendinf_ftp
{
for a in `echo $DATOS | sed 's/=/ /g'`
do
if [[ $x > 1 ]]
then
echo $a | sed 's/#/ /g' >> $logftp
fi
let "x = x + 1"
done
}
the $logftp file contains:
open 111.222.333.444
user test test
binary
prompt off
mput $fpgp2
dir $fpgp2
bye
My doubt here is:
how must i do to see the value of $fpgp2 into $logftp file?
I'm running:
echo $a | sed 's/#/ /g' >> $logftp
i thought that with echo command would show the value of the variable $fpgp2 but NOT !!!
it appears as string but that is a value and that value is given when is invoking the function:
fun_sendinf_ftp $interface_name $functions_path $interface_log $fpgp2
How can i see the value?
I think it must run an exec command or something like that
please help!!!
Thanks !!
Manuales.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2006 04:31 PM
05-14-2006 04:31 PM
Solutionwhat shell r u using??
I have a test on your script, it work!!
#!/bin/sh
fpgp2=hehe
DATOS="open#111.222.333.444=user#test#test=binary=prompt#off=mput#$fpgp2=dir#$fpgp2=bye"
function fun_sendinf_ftp
{
x=1
for a in `echo $1 | sed 's/=/ /g'`
do
if [[ $x > 0 ]]
then
echo $a | sed 's/#/ /g'
fi
let "x = x + 1"
done
}
fun_sendinf_ftp $DATOS
OUTPUT:
open 111.222.333.444
user test test
binary
prompt off
mput hehe
dir hehe
bye
GOOD LUCK!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2006 05:07 PM
05-14-2006 05:07 PM
Re: How can i show a variable value given in a string?
DO NOT WORK!!!
:'(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2006 05:24 PM
05-14-2006 05:24 PM
Re: How can i show a variable value given in a string?
did you try to put a " " on the DATOS= ??
and using ${fpgp2} to call the variable?
BTW, the script also work in ksh.
GOOD LUCK!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2006 09:31 PM
05-14-2006 09:31 PM
Re: How can i show a variable value given in a string?
I can't see, where youre variable x is preset,
try
function fun_sendinf_ftp
{
typeset -i x=0
for a in ...
...
((x+=1))
done
}
mfG Peter