LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-12-2011, 09:06 AM   #1
gujedan
Member
 
Registered: Oct 2010
Posts: 121

Rep: Reputation: 1
get selected file name bash script


Is there any way to get the name(s) of the file(s) selected in the window manager (gnome 2.32) in a bash script?
 
Old 03-12-2011, 12:08 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Wait, what? I am not fully understanding what you are trying to say.
 
1 members found this post helpful.
Old 03-12-2011, 01:41 PM   #3
gujedan
Member
 
Registered: Oct 2010
Posts: 121

Original Poster
Rep: Reputation: 1
I have a bash script foo.sh. I have mapped it to a hotkey in gnome. I select a file or some files on my desktop or nautilus and when i press the aforementioned hotkey, the bash script is invoked. And i need to retrieve the name(s) of the files i currently have selected in the script.

Last edited by gujedan; 03-12-2011 at 01:43 PM.
 
Old 03-12-2011, 01:48 PM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
What you could do is modify the script to take in arguments of files, and add the script to the user script menu in nautilus. What does your script do?
 
1 members found this post helpful.
Old 03-12-2011, 04:26 PM   #5
gujedan
Member
 
Registered: Oct 2010
Posts: 121

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by corp769 View Post
What you could do is modify the script to take in arguments of files, and add the script to the user script menu in nautilus. What does your script do?
nothing much, I'm just looking for a way to map shred -u to a convenient hotkey and use it in nautilus/desktop
 
Old 03-12-2011, 04:57 PM   #6
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Oh, I actually have that set up under nautilus.

System -> Preferences -> Look and Feel -> Nautilus Actions Configuration

File, new action.

Context label - Shred
Tooltip and icon you can set yourself.
Check enabled, uncheck read-only.

Go to the command tab, and use the following:
Label: Shred
Path: shred
Parameters: -f -u -v -z %M

Conditions tab:
Appears if selection contains: Both
Check "Appears if selection has multiple files or folders"


After that, go to file, save.

Enjoy

Note, to access shred, you can select multiple files and folders, right click, and click on shred.
 
1 members found this post helpful.
Old 03-12-2011, 05:00 PM   #7
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
To add to my post though... If you don't have the nautilus actions configuration, do the following as root in a terminal:
Code:
yum install nautilus-actions*
Cheers,

Josh

PS - Here is a site that has many config utilities for nautilus:
http://www.grumz.net/index.php?q=configlist

Last edited by corp769; 03-12-2011 at 05:02 PM.
 
1 members found this post helpful.
Old 03-14-2011, 12:04 PM   #8
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Quote:
Originally Posted by gujedan View Post
nothing much, I'm just looking for a way to map shred -u to a convenient hotkey and use it in nautilus/desktop
After re-reading this, I thought that I should make a point about this, to whomever is reading this: Please tell us exactly what you are doing, what you want to accomplish, and the meaning behind what you are attempting to do. This thread started off in a direction the OP wanted to do, and come to find out, there was such an easier method of doing it. I see this a lot, and you, as the inexperienced user who doesn't know how to ask questions correctly, should definitely read up on how to ask questions the right way (not even who is reading this...). I am not bashing on the OP of this thread what so ever, I am just making a point. So next time, please help us out and fully describe what you want to do!

Cheers,

Josh
 
  


Reply



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
I need a script to Delete Selected BackupFiles and Restore selected backup file finalwar Linux - Newbie 3 07-20-2010 02:10 AM
bash script: use the directory of the script file as variable? phling Linux - Newbie 12 01-16-2010 07:16 PM
Basic bash script question re: file size or # of lines in a file the_fornicator Programming 6 09-03-2009 09:41 AM
Bash script for listing FTP usage as the file name of a file created in each share jojothedogboy Programming 1 12-05-2008 03:35 PM
How to take value from file (bash script) teguh.purnama Linux - Newbie 3 09-08-2008 07:32 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:40 PM.

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
Open Source Consulting | Domain Registration