[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using Cygwin how do I Open a file from Command line

Posted on 2009-04-18
5
Medium Priority
?
896 Views
Last Modified: 2013-11-15
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
Comment
Question by:mdpsolutions
5 Comments
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 150 total points
ID: 24175065
opining a file (text) can be done with

vi filename

0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24175108
0
 
LVL 12

Assisted Solution

by:Hugh Fraser
Hugh Fraser earned 300 total points
ID: 24175118
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
 
LVL 15

Assisted Solution

by:veedar
veedar earned 450 total points
ID: 24175174
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
 
LVL 3

Accepted Solution

by:
Luqman Shantal earned 600 total points
ID: 24177039
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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are like me and like multiple layers of protection, read on!
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…
Suggested Courses
Course of the Month17 days, 15 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question