[SOLVED] what is the linux equivalent of "progname.exe %1"
Linux - NewbieThis 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.
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.
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"
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:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.