Computing.Net > Forums > Linux > Command line -- while

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Command line -- while

Reply to Message Icon

Name: surfistadesampa
Date: November 18, 2004 at 05:49:08 Pacific
OS: Linux
CPU/Ram: Pentium III
Comment:

Hii people uhhuhuhu

i need use the while command in a command line in a c shell and bash

exemple

ssh 172.30.30.30 -l user set a=1; while ( $a <= 10 ); echo $a. set a=`expr #a + 1`; end


this is wrong,, but anyone know how can i get ???



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: November 18, 2004 at 07:35:29 Pacific
Reply:

I don't have access to a bash shell at the moment, but was able to get the below to work (without the ssh). You may not need the " either, but I like to use them around the command.

ssh 172.30.30.30 -l user "a=1; while [ $a -le 10 ]; do echo $a; a=`expr $a + 1`; done"

Be sure to come back and let us know if our suggestions helped!


0

Response Number 2
Name: surfistadesampa
Date: November 18, 2004 at 08:44:39 Pacific
Reply:

nothing happended... this string
a=1; while [ $a -le 10 ]; do echo $a; a=`expr $a + 1`; done

its ok,,, but the problem is i do it in another computer with csh ,, i try many possibilities,,, but its almost impossible...


0

Response Number 3
Name: Wolfbone
Date: November 18, 2004 at 08:46:19 Pacific
Reply:

It's a lot easier if you use the arithmetic expressions and evaluation native to bash:

for ((a=1;a<=10;a++));do echo $a; done


0

Response Number 4
Name: Wolfbone
Date: November 18, 2004 at 09:57:00 Pacific
Reply:

Wait a minute! - you're running in a csh environment on the remote machine?

In the csh manual it says you have to have the 'while' and 'end' statements on a line on their own:

ssh 172.30.30.30 -l user 'set a=1
while ( $a <= 10 )
...
end'


0

Response Number 5
Name: surfistadesampa
Date: November 19, 2004 at 06:38:40 Pacific
Reply:

i have been tried it too,,, but the command "while" execute only 1 time the loop, and it have to be execute 10 times...

yeah,,, i am running csh in a remote machine


huhuhuhuhu it is almost impossible....



0

Related Posts

See More



Response Number 6
Name: Wolfbone
Date: November 19, 2004 at 21:44:33 Pacific
Reply:

Yes - I tried this myself and everything works fine with bash but it does not work with csh. Not much does. ;-)


0

Response Number 7
Name: surfistadesampa
Date: November 23, 2004 at 05:40:36 Pacific
Reply:

huhuhuhu ok,,, thanks friend !! ;)


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Command line -- while

Command line web service invocation www.computing.net/answers/linux/command-line-web-service-invocation/28274.html

command line parameters www.computing.net/answers/linux/command-line-parameters/27611.html

Perl from command line. www.computing.net/answers/linux/perl-from-command-line/12105.html