Re: what is the difference?

From: scriptOmatic (ScriptOmatic_at_ChironComputing.Com)
Date: 04/29/03


Date: Tue, 29 Apr 2003 00:13:15 GMT

Shawn wrote:
>
> Hi,
>
> Could somebody tell me what the difference between these 2 scripts are?
>
> if $status then
> echo "File transfer from cs-vulcan failed"
> exit 1
> endif
>
> ##########
>
> if ($status != 0) then
> echo "File transfer from cs-vulcan failed"
> exit 1
> endif
>
> Thanks!

I assume you are in /bin/csh or /bin/tcsh because these shells
define $status to the the value of the last command executed.

With UNIX, if the last command exited 0 then, of course,
$status == 0 is TRUE.

With UNIX if a command exits with 0 that means SUCCESS and any
value not zero means failure. While this is not strictly true,
because any programmer can intentially break the rule,
it is non-theless true for utilities. Note however, if you
are using an FTP client, many of them do not play by the rules.

YOu can see the NCFTP client and/or you might look at OSM which
includes a file transfer plugin to do what you want above.

Back to the scripts ....

if $status then
...

would mean

if 0 then
   echo failure
and that should be WRONG

but the second script
if ($status != 0) then
 echo failure

is correct (again assuming the copy command plays by the rules).

You might also try, for remote copies, rcp and/or scp.

FYI the OSM implementation allows you to use anonymous and/or passworded
transfers.

-- 
http://ftp.opensysmon.com is a shell script archive site with an
open source system monitoring and network monitoring software package.
Many platforms are supplied already compiled.


Relevant Pages

  • Re: Which processes use shared image
    ... de-install a shared image that someone has open, ... Here's a DCL command procedure that brute forces the solution using ... $ write out "$ exit" ...
    (comp.os.vms)
  • Re: appending syslog output to file
    ... is a shell control operator, ... it (here the 'exit 0' command) is executed ONLY IF the first command ... OK - you'll find that reading these boot scripts (and similar stuff ...
    (uk.comp.os.linux)
  • Re: loop never exits on ESC
    ... I just added following command in my code ... It functions much like the ON KEY LABEL. ... >> ENDIF ... >> EXIT ...
    (microsoft.public.fox.programmer.exchange)
  • Re: vi horizontal split screen
    ... efficient at processing scripts, and one way to do that was substitute ... Microsoft's work for OLE in Windows 1x through 3x. ... As more and more users come to Linux who have no desire for command line ... effectively a programming environment. ...
    (comp.editors)
  • Re: Cron to email notification of ftp file upload?
    ... or traceroute and getting "command not found" messages and then trying to ... >use sudo command when you need to make root privileged changes, ie, ... [ohmster@ohmster scripts]$ sudo crontab -l ... $ cat ftpwatch ...
    (alt.os.linux)