LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 11-15-2003, 09:23 AM   #1
the_rydster
Member
 
Registered: Nov 2003
Location: UK mostly.
Distribution: Slackware 9.1
Posts: 103

Rep: Reputation: 15
Naive scripting question (for Nautilus)


This is only the second script I have ever wrote. Basically I want to be able to send the contents of a directory to trash using the Nautilus scripting facility - Note I want to retain the original directory.

My attempt:

#!/bin/sh

# Send contents to trash

(cd $1)

(mv $(ls) /home/myself/.Trash)

Result is that EVERYTHING in my /home/myself gets to go to Trash.

I understood that $1 argument pertained to the selected file/directory.

Cheers.
 
Old 11-15-2003, 01:25 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,527

Rep: Reputation: 177Reputation: 177
My attempt:

mv ${1}* /home/myself/.Trash

and be sure to put the trailing slash on $1 i.e.

/home/myself/temp/info/

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 11-15-2003, 02:49 PM   #3
the_rydster
Member
 
Registered: Nov 2003
Location: UK mostly.
Distribution: Slackware 9.1
Posts: 103

Original Poster
Rep: Reputation: 15
Hmmmmm

Got this to work from the terminal:

#!/bin/sh

# Send contents to trash

cd $1

mv $(ls $1) /home/myself/.Trash

But it will NOT WORK from the Nautilus file browser so I am bit puzzled - nothing happens. The annoying thing about trying to debug nautilus scripts is that you can't see anything so I kept using the terminal to check it, found it worked, and then that it....er......didn't on Nautilus????

 
Old 11-15-2003, 02:58 PM   #4
the_rydster
Member
 
Registered: Nov 2003
Location: UK mostly.
Distribution: Slackware 9.1
Posts: 103

Original Poster
Rep: Reputation: 15
Just changed:

mv $(ls $1) /home/myself/.Trash

to

mv $(ls) /home/myself/.Trash

Result: it works from Nautilus (although it can't handle spaces in the file names. I'll have to work on that.)

Strange......
 
  


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
Nautilus 2.10.0 question pruhnke Linux - Software 2 09-05-2005 02:14 PM
Naive sendmail setup John Velman Slackware 1 08-30-2005 09:59 AM
suse 9.1 questions (extremely naive) mannis Suse/Novell 5 10-15-2004 11:47 AM
Naive scripting question (for Nautilus) the_rydster Linux - General 0 11-15-2003 10:58 AM
petittion for naive linux half life. schatoor General 13 07-15-2003 04:45 PM


All times are GMT -5. The time now is 03:35 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration