Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-21-2009, 01:58 PM
|
#1
|
Member
Registered: Oct 2003
Location: North London, UK
Distribution: Fedora 14
Posts: 54
Rep:
|
what is the linux equivalent of "progname.exe %1"
I have a one line command that encrypts a file
gpg -c /media/stickname/filename.ext, and it works just fine
BUT
please: What do I do to be able to drag and drop filename.ext onto it to have the same effect. In windoze it is "progname.exe %1".
|
|
|
11-21-2009, 02:20 PM
|
#2
|
Member
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Rep:
|
Quote:
Originally Posted by emuub
I have a one line command that encrypts a file
gpg -c /media/stickname/filename.ext, and it works just fine
BUT
please: What do I do to be able to drag and drop filename.ext onto it to have the same effect. In windoze it is "progname.exe %1".
|
I've got good news and I've got bad news. The good news is that there is an easy way to specify arguments in shell scripts, just as in batch files: in a batch file, you would use %1 to specify the first argument, in a shell script you use $1.
The bad news is that this feature doesn't extend to drag and drop. at least on the Gnome desktop that I'm currently using. Perhaps someone on KDE one of the other desktop environments can comment?
I put the file 'catme' on the desktop:
Code:
#! /bin/bash
cat $1
I made the file executable: chmod 755 ~/Desktop/catme
then dragged a text file over the desktop icon, and nothing fancy happened.
|
|
|
11-21-2009, 03:58 PM
|
#3
|
Member
Registered: Mar 2008
Location: Baltimore Md
Distribution: ubuntu
Posts: 184
Rep:
|
Just make a launcher for your command. In gnome, right-click on a blank space on the desktop, then select "Create Launcher" For type select "application" or "application in terminal" as appropriate. Fill in the command name, don't worry about assigning arguments like $1 or %1. When you drag and drop a file onto this launcher the DE will use the filename as the arg to the command. Incidentally, it is not obvious, but the icon used for the launcher can be changed by clicking on the icon picture in the dialog.
If you need to modify the launcher later, right click on it and select "Properties"
|
|
|
11-21-2009, 04:27 PM
|
#4
|
Member
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Rep:
|
Quote:
Originally Posted by lwasserm
Just make a launcher for your command. In gnome, right-click on a blank space on the desktop, then select "Create Launcher" For type select "application" or "application in terminal" as appropriate. Fill in the command name, don't worry about assigning arguments like $1 or %1. When you drag and drop a file onto this launcher the DE will use the filename as the arg to the command. Incidentally, it is not obvious, but the icon used for the launcher can be changed by clicking on the icon picture in the dialog.
If you need to modify the launcher later, right click on it and select "Properties"
|
That's pretty slick. Couple more points:
- if you're setting up a command line application, make sure that you specify Type as 'Application in Terminal'
- The launcher its self is simply a text file, which seems to be in '.ini' format:
Code:
#!/usr/bin/env xdg-open
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=true
Name[en_US]=test
Exec=/home/tiger/Desktop/catme
Name=test
Looks like interesting things could be learned about xdg-open...
|
|
|
All times are GMT -5. The time now is 04:51 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|