Sponsored Content
Top Forums Shell Programming and Scripting Problem with if statement, cannot get to right directory Post 302993438 by digioleg54 on Thursday 9th of March 2017 04:55:02 PM
Old 03-09-2017
This script is called from another script , which using
Code:
exec

command.
Do0 you mean I don't have to use it?

---------- Post updated at 04:55 PM ---------- Previous update was at 04:42 PM ----------

I will try to explain you.
I have a script, which
Code:
 tar and zip files on remote server when three directories, daily, weekly, monthly

The script went to weekly directory
Code:
 tar, zip files,exit to another server, on which it scp ziped file to our weekly directory, unzip and untar files and
 run another script:
 ${LOCL_WORKING_DIR}/sftp_ondemand.sh /export/data/mbsesb/config/ondemand.cfg /export/data/mbsesb/config/filename.lst W

sftp_ondemand.sh script is supposed to start, cd, to weekly directory on this server and rename files.
However,
Code:
if [ -d ${COOLDIR}/cool_${Today}/daily ] && [ "${CASENAME}" = "D" ]
then
rename daily files, start another script with daily files, also rename
fi
if [ -d ${COOLDIR}/cool_${Today}/weekly ] && [ "${CASENAME}" = "W" ]
then
rename weekly files

fi
if [ -d ${COOLDIR}/cool_${Today}/weekly ] && [ "${CASENAME}" = "M" ]
then
rename monthly files
fi

when I work with weekly files, it is anyway goes to the first if statement and create daily files on weekly directory. Which I don't want to do. I want it to go to the second if statement, but it goes to first, even condition doesn't exists.

Now I explained better?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

if statement problem

I keep getting an error at line 21, it doesn't like my if statement. Previously I have tried using (( )), but still get errors. The current error is that server_busy is not found. This is the script: #! /bin/ksh server_busy="na" for file in $1 $2 $3 $4 $5 $6 do echo " ${file}\t\c" ... (1 Reply)
Discussion started by: coughlin74
1 Replies

2. Shell Programming and Scripting

problem with an IF statement

I need an IF statement that will compare the contents of the variable CX with the actual string "CP". ie. If the contents of $CX are NOT equal to the actual string "CP" then blah blah blah. I have tried a number of things including the following....... if ]; then if ]; then if ];... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

3. UNIX for Dummies Questions & Answers

if statement problem

hi all. i just have a very small problem. i have a menu of 7 choices. i want an if statement so that if the user chooses anything except inside the 1 to 7 range, i can handle the error for it. i tried this: if ] then ....... fi (but it dont work) ...any suggestions? ... (4 Replies)
Discussion started by: djt0506
4 Replies

4. Shell Programming and Scripting

If Statement Problem..

The problem I am having here is that only the 1st option is executed, no matter if I pick yes or no. What am I doing wrong? How can I get this working right without resorting to a case statement? echo "This is the max size your lvol can be:" echo $MAXSIZE echo echo Do you want to max out... (2 Replies)
Discussion started by: LinuxRacr
2 Replies

5. UNIX for Dummies Questions & Answers

if statement problem

See https://www.unix.com/shell-programming-scripting/96846-if-statement-problem.html (0 Replies)
Discussion started by: f_o_555
0 Replies

6. Shell Programming and Scripting

if statement problem

Hi I have a bash script like this if then echo "A" else echo "B" fi $1 is something like 02350 (there is always a trailing '0') and I would like to have an if based on the value of the digits after the 0. Can anybody help? Thanks, Sarah (3 Replies)
Discussion started by: f_o_555
3 Replies

7. Shell Programming and Scripting

problem with if/while statement

I'm trying to have the script check if a file has data or not, and then process it accordingly. If the file is empty, I want it to return "nothing to do", if not, I want it to process the file line by line. This is what I have so far, but it always returns "nothing to do", even if the file is not... (4 Replies)
Discussion started by: ddrew78
4 Replies

8. UNIX for Dummies Questions & Answers

Having problem with if statement

Could someone help me out with this if statement? It's supposed to get a person's website, but it isn't working when I run it. website="" echo "Would you like to enter a website? Enter Yes/No" read choice if then while do echo "Please enter a website:"; read... (4 Replies)
Discussion started by: Sotau
4 Replies

9. Shell Programming and Scripting

Problem if statement

echo "Enter the variable: " " read var1 echo " " for i in ib eb atm do if ; then mv properties environment.properties break else echo "No changes to $var1 " fi done When i run and enter the eb it's not working.Any suggestions please.. (7 Replies)
Discussion started by: bhas85
7 Replies

10. UNIX for Beginners Questions & Answers

Problem with If statement

Hi All, I am writing an if statement to check multiple conditions, but when I try to execute the script it is breaking at the point of if statement by showing the issue below. Code I am using is given below. if -a ] then .... else ... fi I am not understanding... (3 Replies)
Discussion started by: ginrkf
3 Replies
CFETOOLIMPORT(8)					User Contributed Perl Documentation					  CFETOOLIMPORT(8)

NAME
cfetoolimport - import the contents of a database from XML format SYNOPSIS
cfetool import name --file|-f filename [--path|-p directory name] [--daily|-d] [--weekly|-w] [--yearly|-y] [--verbose|-v] [--help|-h] DESCRIPTION
Creates a new database from it's XML representation, in the format created by rrdtool dump. The -d, -w, and -y options specify which databases to create and look for in the dump, and may be combined. If they are all omitted, the default is to only import the weekly database. OPTIONS
--file|-f filename Specifies the XML file to restore. --path|-p The directory in which to create the new database folder. If this argument is not provided, the current working directory will be used. --daily|-d Create a database for recording daily patterns. --weekly|-w Create a database for recording weekly patterns. --yearly|-y Create a database for recording yearly patterns. --verbose|-v Print details of the command's execution to the standard output stream. --help|-h Print a short help message and then exit. EXAMPLE
% cfetool import temperature_copy --path /my/path --file ./temperature.xml Create a new weekly database, "temperature_copy", in the "/my/path" directory, and import it's contents from the file "temperature.xml" in the current working directory. AUTHORS
The code and documentation were contributed by Stanford Linear Accelerator Center, a department of Stanford University. This documentation was written by Elizabeth Cassell <e_a_c@mailsnare.net> and Alf Wachsmann <alfw@slac.stanford.edu> COPYRIGHT AND DISCLAIMER
Copyright 2004 Alf Wachsmann <alfw@slac.stanford.edu> and Elizabeth Cassell <e_a_c@mailsnare.net> All rights reserved. perl v5.8.4 2004-09-21 CFETOOLIMPORT(8)
All times are GMT -4. The time now is 07:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy