Sponsored Content
Full Discussion: if statement sytax
Top Forums UNIX for Dummies Questions & Answers if statement sytax Post 302381518 by tlarkin on Friday 18th of December 2009 02:07:20 PM
Old 12-18-2009
In bash a simple if then construct would work.

Code:
#!/bin/bash

# set file path here

filepath="/path/to/my/file"

# now check if it exists...

if [[ -e $filepath ]]

    then /bin/echo "$filepath already exists"
 
    else `tail -50 /home/redlight/usac.log | grep redlight.rpt | grep "`date | cut -c5-10`" > /home/redlight/usac_ok.txt`

fi

done


The [[ -e ]] checks if it exists.
 

10 More Discussions You Might Find Interesting

1. HP-UX

Network configuration sytax

I'm adding additional route on hpux 11.22 and syntax seems to be wrong to me. However the application works and everything else. Old systax in netconf file. LANCONFIG_ARGS=ether ROUTE_GATEWAY=xxx.xx.xx.xx ROUTE_COUNT=1 ROUTE_DESTINATION=default Note: There are no double Quotations? is this... (0 Replies)
Discussion started by: catwomen
0 Replies

2. UNIX for Advanced & Expert Users

IF statement on a df -g

Im running reports on a unix box. i run df -g and get the disk usage results, what i want to do is hopefully run an if statement or of the sort to highlight any percentages over 80 %. I also would like to run an errpt and also highlight any errors for the current days date. Could the results... (1 Reply)
Discussion started by: hassanj
1 Replies

3. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

4. UNIX for Dummies Questions & Answers

for loop sytax error

Hello folks, I am relatively new to UNIX shell scripting but I have just written this small for loop script below: var="100 300" for ctr in ${var} do echo "$ctr --- $var" done exit 0 But when I am running the script I am getting the error below: ' unexpected: syntax error at line 4 :... (3 Replies)
Discussion started by: Rajat
3 Replies

5. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

6. UNIX for Dummies Questions & Answers

IF statement

Hi I'm currently writing a script that looks at the contents of a file and returns a value, based on a user input- do cat ~/LAFILE | grep "$SYSTEM" | grep "$USERNAME" if ! grep user /etc/passwd >/dev/null 2>&1 then echo "did not find user" else echo "found user" fi break... (4 Replies)
Discussion started by: Great Uncle Kip
4 Replies

7. Shell Programming and Scripting

Help with for statement within while statement

I'm trying to do a for statement within a while read line statement and it's not working. What is wrong with this? while read line do find . -type f -name "*.$line*" -exec gunzip {} \; for file in */*.$line*; do grep ERROR "*.$file*" > error.$line.log; done find . -type f -name... (1 Reply)
Discussion started by: bbbngowc
1 Replies

8. Shell Programming and Scripting

help using if/and/or statement

greetings, the goal below is to test the supplied options/arguments for validity. if the matlab option is not supplied with the additional option of a file then exit. however if matlab IS supplied with its companion option of a file OR batch is the only option then continue on. it's clear the -a... (3 Replies)
Discussion started by: crimso
3 Replies

9. Shell Programming and Scripting

If statement help

I am new to Unix and have been given the task of modifying a current script. Most of the programming I do is Oracle based, not unix. That being said when I run my current script i get the following (not sure if this is an actual error or if it is just being informative) ./test_cron.s: cdev:... (3 Replies)
Discussion started by: biobill
3 Replies

10. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies
scotty(1)							 Tnm Tcl Extension							 scotty(1)

__________________________________________________________________________________________________________________________________________________

NAME
scotty - A Tcl shell including the Tnm extensions. SYNOPSIS
scotty ?fileName arg arg ...? _________________________________________________________________ DESCRIPTION
scotty is a Tcl interpreter with extensions to obtain status and configuration information about TCP/IP networks. After startup, scotty evaluates the commands stored in .scottyrc and .tclshrc in the home directory of the user. SCRIPT FILES
If scotty is invoked with arguments then the first argument is the name of a script file and any additional arguments are made available to the script as variables (see below). Instead of reading commands from standard input scotty will read Tcl commands from the named file; scotty will exit when it reaches the end of the file. If you create a Tcl script in a file whose first line is #!/usr/local/bin/scotty2.1.11 then you can invoke the script file directly from your shell if you mark the file as executable. This assumes that scotty has been installed in the default location in /usr/local/bin; if it's installed somewhere else then you'll have to modify the above line to match. Many UNIX systems do not allow the #! line to exceed about 30 characters in length, so be sure that the scotty executable can be accessed with a short file name. An even better approach is to start your script files with the following three lines: #!/bin/sh # the next line restarts using scotty exec scotty2.1.11 "$0" "$@" This approach has three advantages over the approach in the previous paragraph. First, the location of the scotty binary doesn't have to be hard-wired into the script: it can be anywhere in your shell search path. Second, it gets around the 30-character file name limit in the previous approach. Third, this approach will work even if scotty is itself a shell script (this is done on some systems in order to handle multiple architectures or operating systems: the scotty script selects one of several binaries to run). The three lines cause both sh and scotty to process the script, but the exec is only executed by sh. sh processes the script first; it treats the second line as a comment and executes the third line. The exec statement cause the shell to stop processing and instead to start up scotty to reprocess the entire script. When scotty starts up, it treats all three lines as comments, since the backslash at the end of the second line causes the third line to be treated as part of the comment on the second line. VARIABLES
Scotty sets the following Tcl variables: argc Contains a count of the number of arg arguments (0 if none), not including the name of the script file. argv Contains a Tcl list whose elements are the arg arguments, in order, or an empty string if there are no arg arguments. argv0 Contains fileName if it was specified. Otherwise, contains the name by which scotty was invoked. tcl_interactive Contains 1 if scotty is running interactively (no fileName was specified and standard input is a terminal-like device), 0 otherwise. PROMPTS
When scotty is invoked interactively it normally prompts for each command with ``% ''. You can change the prompt by setting the variables tcl_prompt1 and tcl_prompt2. If variable tcl_prompt1 exists then it must consist of a Tcl script to output a prompt; instead of out- putting a prompt scotty will evaluate the script in tcl_prompt1. The variable tcl_prompt2 is used in a similar way when a newline is typed but the current command isn't yet complete; if tcl_prompt2 isn't set then no prompt is output for incomplete commands. SEE ALSO
Tnm(n), Tcl(n) AUTHORS
Juergen Schoenwaelder <schoenw@cs.utwente.nl> Tnm scotty(1)
All times are GMT -4. The time now is 11:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy