LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 11-21-2009, 02:58 PM   #1
emuub
Member
 
Registered: Oct 2003
Location: North London, UK
Distribution: Fedora 14
Posts: 54

Rep: Reputation: 16
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".
 
Old 11-21-2009, 03:20 PM   #2
bartonski
Member
 
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Blog Entries: 1

Rep: Reputation: 47
Quote:
Originally Posted by emuub View Post
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.
 
Old 11-21-2009, 04:58 PM   #3
lwasserm
Member
 
Registered: Mar 2008
Location: Baltimore Md
Distribution: ubuntu
Posts: 184

Rep: Reputation: 41
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"
 
Old 11-21-2009, 05:27 PM   #4
bartonski
Member
 
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Blog Entries: 1

Rep: Reputation: 47
Quote:
Originally Posted by lwasserm View Post
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...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"How to run windows exe on linux" cmanraja Linux - Newbie 2 02-09-2009 12:28 PM
Is there an "apt-get" equivalent of "yum list available"? geeeeky.girl Linux - General 3 07-20-2008 09:40 PM
linux equivalent of "mapping network drive"? malangbaba Linux - Networking 3 09-12-2007 12:32 AM
"Wine" starts loading... then quits... Can't install ".exe" jabber32 Linux - Software 1 01-10-2007 07:06 AM
how can I install a ".exe" file in linux ? sean_wang Linux - Software 4 12-18-2004 09:53 PM


All times are GMT -5. The time now is 06:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration