LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-28-2013, 02:59 PM   #1
kskrypnyk
LQ Newbie
 
Registered: Jul 2013
Posts: 1

Rep: Reputation: Disabled
echo don''t works) why?)


function couchbase {
ssh $USER@$IP "
echo "/\$STRING"
echo 'connected to 10.10.2.18'
(
echo set key$Y 0 0 $length
sleep 1
#echo "$STRING"
sleep 1
) | telnet localhost $PORT
"
}
while [ $Y -le $calcstr ]; do
echo $Y
STRING="`sed -n "${Y}p" $FILE_RESULT1`"
echo "$STRING"
length=${#STRING}
echo $length
couchbase "$STRING" "$Y"
let Y=Y+1
done

the valuve $STRING in cycle works normally but in function they don't work, ho i can echo this valuve? please help!
 
Old 07-28-2013, 03:21 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
For one thing, you are passing them as args, so in the function you cannot refer to them as $STRING and $Y - they are $1 and $2 respectively. For another, in the echo in the function you are escaping the $ on $STRING, so you are probably seeing "$STRING" anyway. And if you are passing the string and y values from the loop, you probably also want to pass the length from that context as well.

See the bash scripting guide among others for how this works.

Last edited by astrogeek; 07-28-2013 at 03:33 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP5: echo and print don't display newline abd_bela Programming 4 11-04-2012 10:03 AM
[SOLVED] sed: alone [ /pattern/!d ] works; alone [ s ] works; together =don't work klenot Programming 7 10-23-2010 09:45 AM
boot CD don'n works !! ovparrilla Slackware 2 04-14-2004 11:40 PM
Now It Works, Now It Don't minoltaherbie Linux - Hardware 4 08-28-2003 09:49 PM
Echo /devPrinting doesn't work, echo /usb/lp0 works, Testpage works, Printing doesn't Hegemon Linux - General 3 08-15-2002 01:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration