Sponsored Content
Top Forums UNIX for Dummies Questions & Answers BASH: Change alias to script to add a task Post 302488871 by SilversleevesX on Tuesday 18th of January 2011 03:40:39 PM
Old 01-18-2011
MySQL Found another way to do it.

I appreciate the suggestions. Likely as not I'll be coming up with some scripts very much like this one in the near future, so I'll keep this thread bookmarked.

What I failed to mention is, while I write the filenames I want into the "homeperm" or "curl -o" command, I usually paste in the source URLs from the clipboard of whatever OS I happen to be using. This gave me a bit of a headache just using $1 as input from the line, as curl only saw the filename as I typed it and didn't have anything for a URL. It wasn't until I echo'd what curl was getting for input that I gleaned what I was doing wrong.

Then I thought, "If there's a $1, shouldn't there be a $2? Single spaces are seen by BASH as a break, if not a delimiter, aren't they?" So I tried this line near the top of the script:
Code:
echo -e "$1 $2"

and invoked the script (with a standby alias, "homecourt"). Sure enough, the URL printed to stdout right after the filename as sure as dinner follows lunch. cUrl downloaded the file, and the code I had written to annotate the dates ran smooth as melted butter.

Here's the final script.
Code:
#!/bin/bash
actiondate=$(/usr/bin/date)
echo -e "$1 $2 $actiondate"
clockdate=$(date '+%d %B, %Y.')
myfile=$1
myurl=$2
curl -o $myfile $myurl
fulldate=$(stat -c %y $myfile)
shortdate=${fulldate%.*}
exiv2 -kM"set Exif.Image.DateTimeOriginal Ascii $shortdate" $myfile
exiv2 -kM"set Iptc.Application2.SpecialInstructions String Downloaded $clockdate" $myfile
exiv2 -kM"set Exif.Image.DocumentName Ascii $myurl" $myfile
echo -ne "File $myfile downloaded and annotated with date and time.\n\n"

Thanks again for the suggestions.

BZT
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Query regarding alias and setting bash as a default script

Hi All, I am setting bash as my working shell in my .profile file. So I have written a line : bash as the list line in my .profile I want to use alias as follows: alias me='who am i' When i log in, as expeced I enter the bash shell but alias doesn't work. Is it because the alias is defined... (1 Reply)
Discussion started by: VENC22
1 Replies

2. UNIX for Dummies Questions & Answers

Alias, function or script (bash) to "revert" cd command?

In all of my brief and superficial experience with Unix or Linux, the one curious and consistent thing has been that 'cd ./' (back up one directory level) has done absolutely nothing in any of them. Now I understand that, at least for bash, 'cd ./' appears to have been substituted by 'cd ..' Am... (1 Reply)
Discussion started by: SilversleevesX
1 Replies

3. Shell Programming and Scripting

Idea for an "informative" bash alias or script

I had the idea come into my head that it would be good to have a single command that gave file type, file size, last modification date, and owner/group information, like what one would see in a GUI "Properties" dialog, but all in a terminal window. In my opinion, these statistics about a file... (5 Replies)
Discussion started by: SilversleevesX
5 Replies

4. Shell Programming and Scripting

Unable to change environment variables in bash script

Hello! For the moment some settings in my .bashrc contain the password of my company's firewall, which is not a good idea. I would like to use the string "PASSWORD" set in .bashrc and a script that changes all appearances of "PASSWORD" in the environment variables by the actual password (which... (4 Replies)
Discussion started by: markolopa
4 Replies

5. Shell Programming and Scripting

How to run Cygwin bash from windows scheduled task?

Hmmm.... I love these forums because I always get great prompt responses and I want to ask a question about running bash on windows. Is that allowed? Now I know I can install cygwin cron and run bash that way. Can I run bash from windows schedule task? How? thanks siegfried (1 Reply)
Discussion started by: siegfried
1 Replies

6. Shell Programming and Scripting

How to do one line bash schedule task?

This seems to work: https://www.unix.com/shell-programming-scripting/179705-how-run-cygwin-bash-windows-scheduled-task.html However, I was hoping to avoid writing a 2 line bat files to invoke my cygwin scripts as a scheduled task (since I'm making lots scheduled tasks). I was hoping this would... (1 Reply)
Discussion started by: siegfried
1 Replies

7. Shell Programming and Scripting

Windows Task with Bash script

Hello I have a problem with use bash script in windows task. If I use script by cygwin it's working well. If I use it by Windows task I'm get error Error : ERROR 2 (HY000) at line 2: File '.\xxx.csv' not found (Errcode: 2) Code Line : load data local infile './xxx.csv' REPLACE into... (16 Replies)
Discussion started by: karp
16 Replies

8. Shell Programming and Scripting

Is it possible to change paths inside a bash script?

i have some script with some paths inside it. The idea is to some files which is on desktop copy and move to another location. Problem is that inside script is similar to this: cp test1.zip /root/help/ because I allways have another zip files, does it possible to have some input which ask me... (18 Replies)
Discussion started by: tomislav91
18 Replies

9. Shell Programming and Scripting

Change directory within a bash shell script

Hi, I have been trying to execute the below command by changing directory and then copying contents of one directory to another by doing some file name manipulations in between. However this isnt working since as soon as the statement completes it goes back to the original folder. Can someone... (5 Replies)
Discussion started by: HikingLife
5 Replies
PASTE(1)						    BSD General Commands Manual 						  PASTE(1)

NAME
paste -- merge corresponding or subsequent lines of files SYNOPSIS
paste [-s] [-d list] file ... DESCRIPTION
The paste utility concatenates the corresponding lines of the given input files, replacing all but the last file's newline characters with a single tab character, and writes the resulting lines to standard output. If end-of-file is reached on an input file while other input files still contain data, the file is treated as if it were an endless source of empty lines. The options are as follows: -d list Use one or more of the provided characters to replace the newline characters instead of the default tab. The characters in list are used circularly, i.e., when list is exhausted the first character from list is reused. This continues until a line from the last input file (in default operation) or the last line in each file (using the -s option) is displayed, at which time paste begins selecting characters from the beginning of list again. The following special characters can also be used in list: newline character tab character \ backslash character Empty string (not a null character). Any other character preceded by a backslash is equivalent to the character itself. -s Concatenate all of the lines of each separate input file in command line order. The newline character of every line except the last line in each input file is replaced with the tab character, unless otherwise specified by the -d option. If '-' is specified for one or more of the input files, the standard input is used; standard input is read one line at a time, circularly, for each instance of '-'. EXIT STATUS
The paste utility exits 0 on success, and >0 if an error occurs. EXAMPLES
List the files in the current directory in three columns: ls | paste - - - Combine pairs of lines from a file into single lines: paste -s -d ' ' myfile Number the lines in a file, similar to nl(1): sed = myfile | paste -s -d ' ' - - Create a colon-separated list of directories named bin, suitable for use in the PATH environment variable: find / -name bin -type d | paste -s -d : - SEE ALSO
cut(1), lam(1) STANDARDS
The paste utility is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible. HISTORY
A paste command appeared in Version 32V AT&T UNIX. BSD
June 25, 2004 BSD
All times are GMT -4. The time now is 09:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy