Run UNIX Script from Excel

How to run scripts from Excel and bring results back to excel?

What have u tried?

1 Like

I have some commands which are used to find filenames, counts, previous day files and currently i am running them in directories to get results. Is it possible to call them from excel?

That would be Excel macros, and so MSwindows, no more UNIX...
Therefore wrong forum, moving to windows...

1 Like

Hello santoshdrkr,

I have a few to questions pose in response first:-

  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • How are you opening the connection to the unix server?
  • Is this an ODBC connection to an Oracle Database perhaps?
  • What Unix OS and version are you using?
  • What Windows OS and version are you using?
  • What version of Excel are you using?
  • What are your preferred tools? (C, shell, perl, awk, VB etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.

1 Like

In the past when I wanted to create a spreadsheet based on something that runs in Unix/Linux I create a shell script that runs on a server, which creates a comma delimeted file with the .csv extension and then emails the file to an email address. you can then save the file and open it with Excel. I have had good luck with the comma and double quote delimeter as in:

"field1","field2","field3","field4"...

Mailing files from Linix/Unix is OS dependent. But I used the Perl Mime Libraries, which work well. On Solaris you can also use uuencode or mpack with either mail or sendmail depending on what you have. The Perl Mime libraries are not usually installed by default.

1 Like

Hi rbatte 1,

Actually i am new to this. It would be great if you suggest me process doc's/threads from past. I need to understand the process and then I will implement this.

I have few question's Answers :

  1. this is not a homework/assignment this is a real time thing and I am interested in modifying the process to save time.
  2. .
  3. .
  4. generally we use to log in using server name and credentials.
  5. no idea about connection
  6. how to find unix version?
  7. windows 7
  8. excel 2010/2007
  9. no tools from list
  10. .

Point number 5 is key to answering your question. Without having a connection you would be stuck with ftp-type solutions, scp solutions or what gandolf989 is proposing. As far as I know there is no elegant way of connecting both operating systems, barring perhaps ODBC.

Re-reading the requirements given, I'm wondering if this might be a use for Samba. This could allow the Windows server to map a drive to a shared directory from the Unix server and then run the searches/counts locally without further communication or remote running scripts and getting the output returned.

If that is a viable option then great, but I regret I'm not a DOS batch-file writer or very good with Excel macros/VB.

Robin

Hi,

The only time that I have managed to have any joy doing this type of exercise was by using expect, we did try to use VB and Access - but either we weren't good enough or we couldn't work out how to do it.

Regards

Dave

You really can't run a UNIX script from Excel.

You can collect information on your UNIX system and create an import file (like a comma or other delimited file for import into Excel).

Perhaps what you want is automation of the process and this can be done a number of ways depending on your needs.

AUTOMATED PROCESS FROM WINDOWS

In this case you could use windows scheduler to run Excel and use command line options to automate the Excel session.

You could recreate a VB (Visual Basic), a VBA (Visual Basic for Applications) script, or a Powershell script and run it from Windows scheduler. If using VB or VBA there is a SHELL call that you could use to call SSH to log into the UNIX system and create the CSV/Import flie.
In Powershell you could use SSH directly into the UNIX system. You would need an SSH client like PUTTY).

Once the import file is created you could copy it back with SCP and then the script would call Excel with command line option to import the CSV file created on UNIX.