Change the Windows Batch script to UNIX shell script.
Hi,
When I run the below script in UNIX it's throwing syntax errors. Actually it's a windows batch script. Could anyone change the below Windows Batch script to UNIX shell script...
Script:
REM :: File Name : Refresh_OTL.bat
REM :: Parameters : %1 - Region
REM :: : %2 - Cube Type
REM :: :
REM :: Notes :
REM ============================== set ENVIRONMENT VARIABLES ==========================================
set Region=%1
set CubeType=%2
set CommonPath=\export\home\essbase\OTL_REFRESH
FOR /f "eol=; tokens=1,2,3,4,5 delims=, " %%a IN (%CommonPath%\CubeList_%Region%.txt) DO (
if /i %%b EQU %CubeType% (
SET Server=%%a
SET CubeType=%%b
SET Application=%%d
SET _Application=%%c
SET Database=%%e
))
set OTLUnLockLog=%CommonPath%\Logs\%OTL_Application%_UnLock_Object.log
REM ==================================================================================================== =
essmsh Unlock_Objects.bat %Server% %OTL_Application% %Application% %Database% %OTLUnLockLog%
Hi KenJackson,
Thanks a lot for your support. I have made changes according to your inputs. The modified sccript follows.... Script:
# :: File Name : Refresh_OTL_test.bat
# :: Parameters : $1 - Region
# :: : $2 - Cube Type
# :: :
# :: Notes :
# ============================== set ENVIRONMENT VARIABLES ==========================================
Region=$1
CubeType=$2
CommonPath=/export/home/essbase/OTL_REFRESH
for "eol=; tokens=1,2,3,4,5 delims=," a in $CommonPath/CubeList_$Region.txt;do
if b=$CubeType;then
But still it's throwing error in the FOR line.."syntax error near unexpected token `a'."
My requirement is the Five variables Server, Cubetype, Application, OTL_application, Database..should come from the file "CubeList_$Region.txt".
The content of that file is as follows..
Egfrtsap1,DayGPO,OTLDGPO,Rajx,DayGPO
please help me by providing me the correct script. I'm very new to UNIX. We are using K-shell.
It would help to see the format of the files you are reading. I'm not positive what your intent is, but here's a start:
This finds the first line in which the second field matches and exits the loop. I think that's what you want.
The IFS=, sets the very special IFS variable to the single comma character.
The read a b c d e remainder; reads each line into 6 variables, using the commas (the $IFS character) to delimit fields.
The brackets and comparison operator, [, ] and =, need spaces around them (except for the final semicolon);
You really only need the quotes around the variables, "$1", if they contain spaces.
Of course, you still have to translate Unlock_Objects.
Hi KenJackson,
You are almost there in getting my intent. Purpose of the script:
The purpose of the script is… if the CubeType equals to the second entry of any line of the file CubeList_Europe.txt then the variables Server, CubeType, Application, OTL_Application, Database, OTLUnLockLog should be populated with the rest of entries of the same line.
The CubeList_Europe.txt contains the below information.
; ==================================================================================================== =
; :: File Name : CubeList_Europe.txt
; :: Purpose : This file lists all the Europe Cubes that need to be Outline refreshed.
; :: : The general syntax is 'Server, Cube Type, Application, Application, Cube'
; :: : where the first application is the Outline application, the 2nd app is the
; :: : refreshing app and the cube name applies to both apps.
; :: Creation :
; :: Modifications :
;=================================================================================================== ==
while IFS=, read a b c d e; do
if [ b = $CubeType ]; then
Server="$a"
CubeType="$b"
Application="$d"
OTL_Application="$c"
Database="$e"
break
fi
done < $CommonPath/CubeList_Europe.txt
The script is running fine without any errors. But it’s not populating any values to the defined variables except for “$b”.
The current output is as below: Server=
CubeType=DayGPO
Application=
OTL_Application=
Database=
OTLUnLockLog=/export/home/essbase/OTL_REFRESH/Logs/.log
Except CubeType no other variable got populated.
Hi team,
My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server.
I have completed the first part i.e From windows to using to unix server with the help of psftp.exe
code:
psftp user@host -pw password <... (1 Reply)
Hi everyone,
I've below windows batch script which is used to filter the file contents line by line and assign the matched values to the variables in for loop.
for /F "tokens=1,3 delims=:" %%A in (%LOG_DIR%\PM_IS_workflow_status.log) do (
set "ATTR_NAME=%%A"
if /i "!ATTR_NAME!" EQU "Folder"... (1 Reply)
Hi all,
i need to run a shell script on remote server. I have created file .bat file in windows server with following code,
c:\Users\Desktop\putty.exe -ssh -pw password user@server ./script.sh
i need to run the script.sh in my remote server
Above command is not working, any... (4 Replies)
I wish to create a folder on a unix server B from my windows box using windows batch script.
Below is my windows batch script.
@ ECHO OFF
::Enter your Directory name:
echo Enter your Directory name:
set /p mydir=
plink user1@ServerA
mkdir %mydir%
At plink command i get logged... (7 Replies)
Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh.
Thanks in advance (2 Replies)
Hi,
Is it possible to ftp a huge zip file from windows to unix server using unix shell scripting?
If so what command i need to use.
thanks in advance. (1 Reply)
Good morning all. I have been running into a problem running a simple gawk script that selects every third line from an input file and writes it to an output file.
gawk "NR%3==0" FileIn > FileOut
I am attempting to run this command from a batch file at the command line. I have several hundred... (6 Replies)
I need to execute a shell script kept in unix machine from windows. User id, password area available.
For eg.
There's a shell script wich moves all the logs kept in my home directory to a directory named LOGS.
Now i need to get this done through windows; either using a batch file, or java... (4 Replies)
Hi,
I m trying to connect/establish FTP from unix shell script to my PC.Below the script i have written
#!/bin/ksh
ftp -v -n ddcappip01.com << "EOF"
user Amit jason
bye
EOF
------------------------------ERROR--------------------------
but i m getting the below error for the... (4 Replies)
I am using awk in my .ksh script but when I am trying to run in windows
its not recognising awk part of the ksh script , even when I changed it to gawk it does not work, this is how my .ksh and .bat files look like.
thanx.
#!/bin/ksh
egrep -v "Rpt 038|PM$|Parameters:|Begin |Date: |End... (1 Reply)