Archive Unix script to Batch script

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Archive Unix script to Batch script
# 1  
Old 06-29-2012
Archive Unix script to Batch script

Hi All,

I have a requirement to archive processed file and retain the archive based on the quantity.. but this is in windows.

I have written a drafted shell script, and would like to have it translated into Batch script.. Please...

Below is the drafted shell script

===================================================
Code:
#!/bin/ksh

XCOUNT=$1
FILNME=$2
OUTDIR=$3
ARCDIR=$4

mv $OUTDIR/$FILNME $ARCDIR
cd $ARCDIR

### LIST THE FILES SPECIFIC TO THE FILENAME
ls | grep $FILNME > list.txt

### LOOP
while $XCOUNT > 0 ;
   do
   ### GET THE OLD ARCHIVE
   TMPFIL1=`grep $FILNME.$XCOUNT list.txt`
   TMPFIL2=${TMPFIL1%.*}
   if [[ ! -z ${TEMPFIL1} ]] &&
      [[ $XCOUNT = $1 ]]; then
      rm -f ${TEMPFIL1}
      fi
      
## not sure if this will work.. but the logic is to subtract 1 :)
   XCOUNT=$(($XCOUNT-1))            
   if [[ -z ${TEMPFIL1} ]]; then
      continue
      fi
   
   mv $TEMPFIL1 $TMPFIL2.$XCOUNT
   done

===============================================


Moderator's Comments:
Mod Comment Please view this code tag video for how to use code tags when posting code and data.

Last edited by vbe; 06-29-2012 at 12:09 PM.. Reason: code tags...
# 2  
Old 06-29-2012
If I understand your request, you want this unix shell script converted to DOS .bat file ?
If so you are in the wrong forum...
Moved to more suitable.
# 3  
Old 06-30-2012
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies

2. Shell Programming and Scripting

SFTP or scp with password in a batch script without using SSH keys and expect script

Dear All, I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
Discussion started by: ss112233
5 Replies

3. Shell Programming and Scripting

Batch script to execute shell script in UNIX server

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)
Discussion started by: bhupeshchavan
1 Replies

4. Shell Programming and Scripting

Windows Batch script for Unix commands

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)
Discussion started by: mohtashims
7 Replies

5. Shell Programming and Scripting

Dos batch script to execute unix shell script

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)
Discussion started by: Shri123
2 Replies

6. Shell Programming and Scripting

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 ::... (5 Replies)
Discussion started by: tomailraj
5 Replies

7. Shell Programming and Scripting

How to execute multiple(batch) oracle script in unix mechine

Hi All, How to run multiple oracle script in unix at-a-time.I appriciate if any send the script for me. Regards, Ravi kumar.Gongati (2 Replies)
Discussion started by: ravi gongati
2 Replies

8. UNIX for Dummies Questions & Answers

UNIX logon script/batch

Hi everyone, I am a newbies to Unix and hope someone can help me on: 1. Do anyone has batch file example that can be logon to a unix sever through telnet and exec a nohup command without typing in username and passward everytime ? 2. A java script exmaple for doing the same logon so it... (1 Reply)
Discussion started by: oht
1 Replies

9. Shell Programming and Scripting

how to convert unix .ksh script to windows .batch script

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)
Discussion started by: 2.5lt V8
1 Replies

10. Shell Programming and Scripting

How to write a Script to run series of batch jobs on unix platform

Im new to unix shell scripting, I have to run batch jobs on unix. for example i have 5 jobs. first 2 can kickoff parallely. after completely finishing the 2 previous jobs the 3 job should kick off..once 3rd is over 4 th and 5th can kick off parallely. Each jobs run for 1 or 2 hours each. How to... (2 Replies)
Discussion started by: venki311
2 Replies
Login or Register to Ask a Question