Sponsored Content
Top Forums Shell Programming and Scripting Create a .sh file for an equivalent Excel VBA code Post 302599377 by bansalpankaj88 on Friday 17th of February 2012 02:03:49 AM
Old 02-17-2012
Create a .sh file for an equivalent Excel VBA code

Hi guys,
I am new to Unix, Need your help here.
I have installed cygwin software (Unix) in my computer (Windows vista). Now i want to create a shell script (.sh file)/other script which is equivalent of VBA code (at the bottom) and then put this .sh file into bin directory of c:/cygwin.
so when i login into cygwin and type some command, it should be able to perform the same function as in VBA code.
Please help me out with this script and its programming.

VBA code:
Code:
Sub Macro3()
    sFile = Application.GetOpenFilename("All files (*.*), *.*", 1,  "Select Input File", "Open", False)         'asks for file location
    If TypeName(sFile) = "Boolean" Then             ' if input file "Kget_utran cell" is not provided, exit.
        Exit Sub
    End If
    f = FreeFile
    Open sFile For Input As f
    strfile = Input(LOF(f), #f)     ' read whole file into variable
    Close f    ' no need to keep file open
    Do
      strt = Strings.InStr(strfile, "Bye...")       'Gives start value of this string in the input file.
      If strt = 0 Then Exit Do    ' not found finish
      nd = InStr(strt, strfile, ".log") + 5
      pp = Mid(strfile, (strt - 16), (nd - strt + 16))
      strfile = Replace(strfile, pp, "")
    Loop
    Length = Len(sFile)
    j = 1
    rr = 1
    Do Until rr = 0
        rr = InStr(j, sFile, "\")
        If rr = 0 Then
            GoTo here
        End If
        j = rr + 1
    Loop
here:    y = Left(sFile, j - 2)
    Open y & "\output.txt" For Output As f      'saves at this location
    Print #f, strfile
    Close f
    MsgBox "DONE"
End Sub


Last edited by Franklin52; 02-17-2012 at 04:25 AM.. Reason: Please use code tags for code and data samples, thank you
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Hw to create root-equivalent accounts?

Hi all. After installing ssh on a server, i'd like to create a user with root privileges. My problem is that after creating a user rootssh (uid=0, gid=20, /home/rootshh), i make rootssh's ssh keys. The problem is that normally the ssh-keygen should create the keys under $HOME/.ssh/, and actually... (6 Replies)
Discussion started by: penguin-friend
6 Replies

2. UNIX for Dummies Questions & Answers

create excel file

Hi, How can I create an excel file from a txt file using shell script. Please do a help for me. Thanks, Regards, Milton (6 Replies)
Discussion started by: miltony
6 Replies

3. Shell Programming and Scripting

Create an .csv/excel file using shellscript

In my file, i have 4 Product names(For ex:Microsoft excel, Oracle,.Net,IBM websphere,..etc.,) I want this 4 Products in 4 individual .csv/excel file after running the script with those products related information. (12 Replies)
Discussion started by: Navya
12 Replies

4. Shell Programming and Scripting

create separate files from one excel file with multiple sheets

Hi, I have one requirement, create separate files (".csv") from one excel file(xlsx) with multiple sheets. These ".csv" files are my source files. So anybody please suggest me the process. Thanks in Advance. Regards, Harris (3 Replies)
Discussion started by: harris
3 Replies

5. UNIX for Dummies Questions & Answers

Create the equivalent of the command WC

hi all, i'm trying to do this exercise, i want to create a script that can substitute WC command in unix, can someone help me? (11 Replies)
Discussion started by: Marina2013
11 Replies

6. Shell Programming and Scripting

Create excel file using bash script

i have written one script which generates text file which gives output like. 001.config: CR1.1 COMPILE_PASSED TEST_PASSED 002.config: CR1.1 COMPILE_FAILED TEST_FAILED . . .so on this text file will get filled one by one as its for loop for n number. i... (7 Replies)
Discussion started by: RamMore123
7 Replies

7. UNIX for Dummies Questions & Answers

How to Create excel file(.csv) using shell script?

Hi, i have shell script which compiles n number of test cases and execute them one by one. i want to create report in excel through script in which two columns namely "test id" and "release".second column have two subcolumns namely compiles and excutes. so i want first column should display test... (15 Replies)
Discussion started by: RamMore123
15 Replies

8. Windows & DOS: Issues & Discussions

Excel VBA script aware of being opened interatively or from the command line

I have a Excel VBA script that automatically runs when opened, extracts one table from a Microsoft Access Database, saves it as CSV, closes it, extracts another, saves it as CSV, closes it, then terminates itself. Is is called from a short .bat file using the /e option so that Excel does not... (1 Reply)
Discussion started by: Michael Stora
1 Replies

9. Windows & DOS: Issues & Discussions

Update sh file using VBA before perl script is run

I have a VBA that creates a new directory folder and creates a new text file in that directory. I am trying to run a perl script from the VBA and have created a batch file that gets called from the VBA. That bat file uses a shell file to run a script. When the batch file is called I get the error... (0 Replies)
Discussion started by: cmccabe
0 Replies
STRFILE(1)                                                 UNIX System Manager's Manual                                                 STRFILE(1)

NAME
strfile - create a random access file for storing strings unstr - dump strings in pointer order SYNOPSIS
strfile [-iorsx] [-c char] sourcefile [outputfile] unstr [-c char] datafile[.ext] [outputfile] DESCRIPTION
strfile reads a file containing groups of lines separated by a line containing a single percent `%' sign (or other specified delimiter character) and creates a data file which contains a header structure and a table of file offsets for each group of lines. This allows ran- dom access of the strings. The output file, if not specified on the command line, is named sourcefile.dat. The purpose of unstr is to undo the work of strfile. It prints out the strings contained in the sourcefile, which is datafile.ext without its extension, or datafile if no extension is specified (in this case, the extension .dat is added to the name of the datafile) in the order that they are listed in the header file datafile. If no outputfile is specified, it prints to standard output; otherwise it prints to the file specified. unstr can also universally change the delimiter character in a strings file. It is possible to create sorted ver- sions of input files by using strfile -o and then using unstr to dump them out in the table order. Options The options are as follows: -c char Change the delimiting character from the percent sign to char. This option is available for both strfile and unstr. -i Ignore case when ordering the strings. -o Order the strings in alphabetical order. The offset table will be sorted in the alphabetical order of the groups of lines refer- enced. Any initial non-alphanumeric characters are ignored. This option causes the STR_ORDERED bit in the header str_flags field to be set. (It also now really does sort! It didn't used to). -r Randomize access to the strings. Entries in the offset table will be randomly ordered. This option causes the STR_RANDOM bit in the header str_flags field to be set. (And really does randomize) -s Run silently; don't give a summary message when finished. -x Note that each alphabetic character in the groups of lines is rotated 13 positions in a simple caesar cypher. This option causes the STR_ROTATED bit in the header str_flags field to be set. Note that it does not rotate the strings--that operation must be per- formed separately. Header The format of the header is: #define VERSION 1 unsigned long str_version; /* version number */ unsigned long str_numstr; /* # of strings in the file */ unsigned long str_longlen; /* length of longest string */ unsigned long str_shortlen; /* shortest string length */ #define STR_RANDOM 0x1 /* randomized pointers */ #define STR_ORDERED 0x2 /* ordered pointers */ #define STR_ROTATED 0x4 /* rot-13'd text */ unsigned long str_flags; /* bit field for flags */ char str_delim; /* delimiting character */ All fields are written in network byte order. BUGS
Fewer now, one hopes. However, fortunes (text strings) beginning with a blank line appear to be sorted between random letters. This includes ASCII art that contains no letters, and first lines that are solely non-alphanumeric, apparently. I've no idea why this should be. OTHER USES
What can you do with this besides printing sarcastic and obscene messages to the screens of lusers at login or logout? There are some other possibilities. Source code for a sample program, randstr, is included with this distribution: randstr splits the dif- ference between unstr and fortune. It reads a single, specified file, and randomly selects a single text string. 1 Include strfile.h into a news reading/posting program, to generate random signatures. Tin(1) does something similar, in a much more complex manner. 2 Include it in a game. While strfile doesn't support 'fields' or 'records', there's no reason that the text strings can't be consis- tent: first line, a die roll; second line, a score; third and subsequent lines, a text message. 3 Use it to store your address book. Hell, some of the guys I know would be as well off using it to decide who to call on Friday nights (and for some, it wouldn't matter whether there were phone numbers in it or not). 4 Use it in 'lottery' situations. If you're an ISP, write a script to store login names and GECOS from /etc/passwd in strfile format, write another to send 'congratulations, you've won' to the lucky login selected. The prize might be a month's free service, or if you're AOL, a month free on a real service provider. SEE ALSO
byteorder(3), fortune(6) HISTORY
The strfile utility first appeared in 4.4BSD. This version was heavily modified, much of it in ways peculiar to Linux. Work has since been done to make the code more generic, and has so far been tested to work with SunOS 4.x. More platforms are expected to be supported as work continues. 4th Berkeley Distribution June 9, 1993 [Apr. '97] STRFILE(1)
All times are GMT -4. The time now is 06:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy