• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 930
  • Last Modified:

Using Cygwin how do I Open a file from Command line

Ok I am new to all of this and know very little about Linux/Unix. Just really using the program for SSH to our routers but figured what the heck lets have a little fun.  So I started reading and reading and I think I am starting to like this stuff but was trying to find the command or to see if this is possible; basically I want to open a file in its default application from command line.  Found a command "open"  tried it and got -bash: open: command not found.  So I know you experts would know any help and possible website where I can learn about the capabilities would be greatly helpful.
0
mdpsolutions
Asked:
mdpsolutions
4 Solutions
 
omarfaridCommented:
opining a file (text) can be done with

vi filename

0
 
omarfaridCommented:
0
 
Hugh FraserConsultantCommented:
The command shell in Cygwin is Bash, and like all Unix shells, it doesn't directly support the concept of associating a file type with a default application. I haven't seent the "open" command you're referring to. The normal technique is to create a shell script that contains a link to the appropriate executable in the first line with a specific format:

#! /usr/bin/perl
some
... perl
.......code

This can be saved in a file called "do_this.pl", and if it has the execute bit set in the file permissions, typing:

   ./do_this.pl

will execute the perl program. Of course, this doesn't work for something like a gif image that needs to open a viewer.

Unix (and I assume Cygwin) has a command called "file" that will identify the type of file. I suppose it would be possible to create an "open" script that checks the file type, and executes the appropriate command from a list of known associations.
0
 
veedarCommented:
It depends on the application. Take notepad for example say you have a file abc.txt from the command line you can open it in notepad with:

notepad  abc.txt

In general you want to check the application documentation to see what command line options it supports.

Cygwin is very useful to learn more google cygwin tips and tricks...

http://www.nabble.com/Cygwin-Windows-DOS-integration:-Tips-and-Tricks-p14472002.html

http://successtheory.com/tips/cygwintips.php
0
 
Luqman ShantalPrincipalCommented:
When I deal with routers, I prefer using putty, it's free and less bloated for this specific purpose.

However, you could always use the: "less" command to view file contents.

In essence, that is the best way besides using the vi editor if you want to edit.

Using the "less" command, you can then scroll up and down using the keyboard up and down arrows.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now