- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: commands while and for , in command line ...
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
03-02-2006 06:09 AM
03-02-2006 06:09 AM
why can i not run while or for in command line?
server:user1 25> while true
while: Expression syntax.
other times i can execute follows:
server:user1 25> while true
> do
> ps -fea | grep procs
> sleep 1
> done
....
....
and i can see result ..
...
...
actually i'm using csh with this user ...
thanks Manuales.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2006 06:18 AM
03-02-2006 06:18 AM
SolutionIf you are running a C-shell (csh) then your syntax is wrong. It should look like:
while (1)
echo "hi"
sleep 1
end
That said, I would avoid the 'csh' at all costs. It's deficiencies are discussed here:
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
The Posix (HP-UX default), or the Korn shell are far, far superior.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2006 06:20 AM
03-02-2006 06:20 AM
Re: commands while and for , in command line ...
Unlike the Korn and POSIX shells, the csh does not have a "true" built in command. That's why it gives you the error. The csh alternative to the "true" builtin is the number 1 i.e.
while 1 == while true
The while command that's running ok has the ksh/POSIX shell syntax because the csh while looks like...
while (expr)
cmds
end
hope it helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2006 06:22 AM
03-02-2006 06:22 AM
Re: commands while and for , in command line ...
That's because csh does *not* support the "true" & "false" while arguments - the bourne, korn & Posix do however.
You need an actual control_command for csh - that's just one of the reasons I hate csh.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2006 10:13 AM
03-07-2006 10:13 AM
Re: commands while and for , in command line ...
i have worked with while (1) ...
but ... how can i work with "for" sentence?
do i must writte "for (2)",or what?
Thanks, Manuales.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2006 10:21 AM
03-07-2006 10:21 AM
Re: commands while and for , in command line ...
The csh does not have a for loop...instead it provides the "foreach" statement:
foreach name (wordlist)
commands
end
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2006 11:26 AM
03-07-2006 11:26 AM
Re: commands while and for , in command line ...
The 'csh' "foreach" loop walks a list of elements, like this:
#!/usr/bin/csh
foreach i (1 3 5 7 9 11)
if ( $i == 3 ) then
continue
else if ( $i == 9 ) then
break
endif
echo "I see ${i}"
end
...
The 'foreach' is different, therefore, from the C-language 'for' statement.
You can use 'continue' and 'break' to skip processing or terminate the loop altogether.
For instance, in the above, we start out as if we are going to do something with the values 1, 3, 5 7, 9 and 11.
The 'continue' skips the value of "3" and the 'break' terminates the loop. Thus, running the snippet above would produce:
I see 1
I see 5
I see 7
Have a look at the manpages for 'csh' using the above example:
http://www.docs.hp.com/en/B2355-60127/csh.1.html
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2006 11:44 AM
03-07-2006 11:44 AM
Re: commands while and for , in command line ...
:0)
Manuales.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2006 11:51 AM
03-07-2006 11:51 AM
Re: commands while and for , in command line ...
Thank *you*! I enjoy helping and teaching.
Regards!
...JRF...