Sponsored Content
Full Discussion: arguments in bash
Top Forums Shell Programming and Scripting arguments in bash Post 302582888 by elginmulizwa on Monday 19th of December 2011 01:42:07 AM
Old 12-19-2011
Network arguments in bash

This script moves all the doc files to a specified directory. I have managed to put an argument but the problem I am facing is putting the full path where the scripts are moving to, for example I want to run the script like this below

./loo -d then path where im moving the files (i.e ./loo -d the second argument where files are moving to)

i want to replace $To in the existing script with the command argument after -d ...
this code is not working i dont know why....

Code:
#!/bin/bash
From="/home/elg19/lone/doc"
To=$2

if [ $1 = -d ]; then
    cd "$From"
    for i in pdf txt doc; do
      find . -type f -name "*.${i}" -exec mv "{}" "$To" \;
    done
fi


Last edited by Franklin52; 12-19-2011 at 03:30 AM.. Reason: Please use code tags for code and data samples, thank you
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash Shell - # of arguments

Hi!, How can I check the number of arguments passed from the shell in a bash shell ? (1 Reply)
Discussion started by: DNAx86
1 Replies

2. Shell Programming and Scripting

Make a list in bash out of arguments

Hello, I have a very stupid/simple problem, but for some reason I cannot figure out...and I need your help! I am writting a bash scrip that should be executed using "my_script X Y Z T" where X Y Z and T can be any string, but there can be any number of arguments. I want my script to do... (4 Replies)
Discussion started by: jolecanard
4 Replies

3. Shell Programming and Scripting

bash functions arguments

This script is called fuu; #!/bin/bash speak() { case $1 in 1)echo one ;; 2)echo two ;; 3)echo three ;; esac } speak exit 0 when i run fuu 2 i expect "two" like... (2 Replies)
Discussion started by: Tártaro
2 Replies

4. Homework & Coursework Questions

BASH Environment Variables as arguments?

1. The problem statement, all variables and given/known data: Write a shell program called myenv which takes one argument. The argument should be the name of an environment variable, such as PATH HOME etc. myenv should print out the value of the variable given as the argument. If no argument is... (1 Reply)
Discussion started by: Helix
1 Replies

5. Shell Programming and Scripting

Bash too many arguments error

Hello, I've got this little script that gets a bunch of comics and puts them in an html file. However, when I check that the comic URL is there and that it's a new one, I get the "too many arguments" error. The script is this: CADURL=`curl --silent http://www.cad-comic.com/cad/ | grep -o... (10 Replies)
Discussion started by: killer54291
10 Replies

6. Shell Programming and Scripting

bash read within function with arguments

I have trouble getting this logic to work #!/bin/bash function assign_var(){ while do read -p "$2 :" $3 done } assign_var '$IPADDRESS' ipaddress IPADDRESS Basicly, i want to make sure that entry is made (i can add more sophisticated checks later), but the idea is to recycle... (11 Replies)
Discussion started by: serverchief
11 Replies

7. Shell Programming and Scripting

arguments in bash

this script moves all the doc files to a specified directory....i have managed to put an argument but the problem im facing is puting the full path where the scripts are moving to for example i want to run the script like this below ./loo -d then path where im moving the files (i.e ./loo -d the... (2 Replies)
Discussion started by: elginmulizwa
2 Replies

8. Shell Programming and Scripting

Bash script with arguments

Could someone help me with the script below? I am trying to make a script having just one arguement as a command and then it executes the appropriate code #!/bin/bash if then echo "Available commands:" echo "./exec.sh cmd1" echo "./exec.sh cmd2" elif then cmd1 =... (1 Reply)
Discussion started by: spiridakos
1 Replies

9. Shell Programming and Scripting

Passing arguments to a bash script

Hi, I wanted to pass an argument to a bash script. So that the argument is used inside the awk command inside the bash script. I know the noraml way of passing argument to a bash script as below : sh myScript.sh abc Inside the bash script i can use like this myArg1=$1 wc $myArg But... (8 Replies)
Discussion started by: shree11
8 Replies

10. Shell Programming and Scripting

[bash] cd: too many arguments

Hello everyone, Could someone please explain to me why I get cd: too many arguments when I select a dir that has one or more spaces in the name? This is the code #!/bin/bash tmp_loc=$(zenity --file-selection --directory) if ]; then exit 0 else location=${tmp_loc// /\\ } # this... (7 Replies)
Discussion started by: soichiro
7 Replies
rdeliver(1)						      General Commands Manual						       rdeliver(1)

NAME
rdeliver - Ruby mail filter script SYNOPSYS
rdeliver <options> [script] DESCRIPTION
This script serves as an example of how you can use the RFilter::DeliveryAgent class to perform mail delivery. You can also use this script as a fully functioning mail filter. This script is a basic mail local delivery agent (DeliveryAgent) that can be used in place of procmail, maildrop, etc. in a user's .forward or .qmail file. The user supplies a delivery script that is written in Ruby, which avoids the limitations of the crippled mini-languages so often used in other DeliveryAgent programs. USAGE
rdeliver is invoked from the command line using: % rdeliver <options> [script] The script argument is optional. If omitted the script will look for a file called .rdeliver in the home directory. Options are: --load-path directory Prepend the given directory to ruby's load path. --log filename Log to the given filename. If no log is specified, no logging occurs. --home directory Specify the home directory. rdeliver will change to this directory before reading and writing any files. The home directory defaults to the value of the HOME or LOGDIR environment variable. DELIVERY SCRIPT
The delivery script runs in the context of a class called Deliver (in contrast, most ruby scripts run in the context of the Object class). So any methods added with def will be added to the Deliver class. A minimal delivery script would be: def main agent.save('inbox') end This code defines a Deliver#main method that saves the mail into an mbox style mailbox. The only API the Deliver script has is the #agent method. This retrieves the RFilter::DeliveryAgent object associated with the current message. Using the API of the RFilter::DeliveryAgent object, you can access and modify the message body and headers, defer or reject the message delivery, and deliver into various mailbox formats. See also RFilter::DeliveryAgent and Deliver. INSTALLATION
Assuming you have the RubyMail mail classes installed, you typically have to put something like this in your .forward file: |"/usr/bin/rdeliver --log /home/you/.rlog" This will call rdeliver for each new message you get, and log to /home/you/.rlog. CATASTROPHIC ERRORS
The rdeliver script is very careful with errors. If there is any problem, it logs the error to the log file you specify. But if you do not specify a log file, or the error occurs before the log file is opened, a record of the error is placed in a file called CATASTROPH- IC_DELIVERY_FAILURE in the home directory. If that fails, the error information is printed to the standard output in the hopes that it will be part of a bounce message. In all cases, the exit code 75 is returned, which tells the MTA to re-try the delivery again. AUTHOR
rdeliver and RFilter support classes were written by Matt Armstrong <matt@lickey.com>. This document was originally an RD format document of rdeliver script. This manual page was converted from it for Debian GNU/Linux system. September 2003 rdeliver(1)
All times are GMT -4. The time now is 01:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy