- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- If sentence ..
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
Discussions
Discussions
Forums
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
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
тАО12-14-2005 06:15 AM
тАО12-14-2005 06:15 AM
Re: If sentence ..
if ($bb = 1) then
echo "hola"
else
echo "adios"
endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 06:17 AM
тАО12-14-2005 06:17 AM
Re: If sentence ..
Your script should be:
if ( $bb == 1 ) then
echo "hola"
else
echo "adios"
endif
Note the differences.
1st line -- You needs space between the open and close parentheses and the expressions. Also you needed a '==' (2 equal signs together) and the 'then' needs to be on the first line.
The last line of the script has to be 'endif'.
# man csh
will give you a LOT of info on the C-shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 06:28 AM
тАО12-14-2005 06:28 AM
Re: If sentence ..
i've worked with ksh ..
do you know if with csh you can make functiions llike ksh? it means, with ksh there is a variable specially to redirect a path where there will be functions .. do you kwno if this exists to csh?
Thanks, Manuales.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 06:35 AM
тАО12-14-2005 06:35 AM
Re: If sentence ..
The 'csh' shell is far inferior to the Posix ('usr/bin/sh'), 'ksh', and 'bash' shells.
See here, for one discussion of why *not* to use 'csh':
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
Beyond, that, on HP-UX, for the 'root' account, in '/etc/passwd', NEVER specify any shell other than '/sbin/sh'. To do so will render your server unusable.
The Posix shell lives in '/sbin/sh' as a staticly-linked binary. As such, everything it needs to run is available in single-user mode (when '/usr' isn't mounted). The Posix shell in '/usr/bin/sh' is for general users and uses dynamically linked libraries in '/usr'. Non-root users should specify this shell in preference to '/sbin/sh'.
Regards!
...JRF...
- Tags:
- scummy C shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 06:47 AM
тАО12-14-2005 06:47 AM
Re: If sentence ..
I try to avoid it if at all possible. I much prefer the POSIX shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 08:15 AM
тАО12-14-2005 08:15 AM
Re: If sentence ..
i have a problem,
running script manually is ok. but if i run it from cron i have an error:
/home/scripts/test.sh[21]: Syntax error at line 56 : `else' is
not matched.
why?
my script is:
#!/usr/bin/csh
set p_monit=/home/scripts/MONITORING
#--->12132005 This is to take correct name in script
cd /interface/Towers/exe/backup
set aa=`ls -l | grep earn | awk '{ print $NF }'`
set bb=`echo $aa | wc -w`
if ($bb == 1) then
mv $aa db.opo
chmod 775 db.opo
else
set mensaje=`cat $p_monit/mail_messages.txt | grep 01 | cut -d":" -f2`
echo $mensaje | mailx -s "01 ORANGE ALERT to Mexico" me@patito.com.mx
endif
Thanks, Manuales.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 08:27 AM
тАО12-14-2005 08:27 AM
Re: If sentence ..
The 'cron' environment is quite sparse, containing:
HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh
That is, *any* variables that are usually in your profile or login file are *not* available unless you specifically include them.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 08:31 AM
тАО12-14-2005 08:31 AM
Re: If sentence ..
/home/scripts/test.sh[21]: Syntax error at line 21 : `if' is not matched
Thanks, Manuales.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 08:32 AM
тАО12-14-2005 08:32 AM
Re: If sentence ..
put su - user before the script in your crontab
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2005 08:34 AM
тАО12-14-2005 08:34 AM
Re: If sentence ..
put su - USERNAME in front the script in your crontab
Regards