Script to prompt user to enter data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to prompt user to enter data
# 1  
Old 03-15-2013
Script to prompt user to enter data

Hi All

I have a script that moves files from one dir to another dir based on date, but I would like to change it in a way that whoever is going to run to enter the dates in which files will be removed. This is my script:

Code:
#!/bin/sh
touch -mt 201302250000 /tmp/ref3
touch -mt 201302282359 /tmp/ref4
find /data/xzy/abc/processed -type f \( -newer /tmp/ref3 -a ! -newer /tmp/ref4 \) > file_lst
mv $(< file_lst) /data/xzy/abc/processed/Feb13/

Please can you help
# 2  
Old 03-15-2013
Read the time stamps from the user using "read" and then touch the files "on those time stamps".
# 3  
Old 03-15-2013
Script to prompt user to enter data

Hi

Thanks for the reply.
Would it be:
Code:
echo "pls enter starting date format YYYYMMDDHHMM:"
read star_date
echo "pls enter end date format YYYYMMDDHHMM:"
read end_date

# 4  
Old 03-15-2013
Yes Smilie
# 5  
Old 03-15-2013
Script to prompt user to enter data

Then....

will it be:

Code:
touch start_date /tmp/ref1
touch end_date /tmp/ref2

# 6  
Old 03-15-2013
no!!!!

Code:
 
touch $start_date /tmp/ref1
touch $end_date /tmp/ref2

Variables should have "$" in front of their names Smilie
# 7  
Old 03-15-2013
Script to prompt user to enter data

Hi

This is what I did, but its not working:

Code:
#!/bin/sh

echo "pls enter starting date format YYYYMMDDHHMM:"
read star_date
echo "pls enter end date format YYYYMMDDHHMM:"
read end_date

touch $start_date /tmp/ref1
touch $end_date /tmp/ref2


find /tmp/fr -type f \( -newer /tmp/ref1 -a ! -newer /tmp/ref2 \) > file_lst
ls -lrt $(< file_lst) /tmp/fr

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Auto enter for prompt messages

Hello everybody, I am coding a script, that allow the user to enter some information using prompt messages, i.e: sEpisode=1 read -e -i "$sEpisode" -p "Start download from episode: " downloadFrom sEpisode="${downloadFrom:-$sEpisode}" This code allows the user to set the download from... (4 Replies)
Discussion started by: Abu Rayane
4 Replies

2. UNIX for Dummies Questions & Answers

TWO QUESTIONS...How to create your own command in UNIX server,How to enter data in a file by script

I am a quite newbie on UNIX SCRIPTING...Please help me solving this two questions... 1st Question; I want to create one command that will run a script when anyone use that command on that server... I mean, in the prompt if I put my name 'Rony' it will execute a script called 'rony.sh'. How can... (1 Reply)
Discussion started by: Rony-123
1 Replies

3. Shell Programming and Scripting

how to prompt the user to enter an array in tcsh

Hello, I am writing a script that requires the user to enter a string of numbers: ex: 134 345 865 903 This command only allows for one variable to be entered: set "var" = $< and than once I got the array I want to change it to a list with each input on a different line: ... (1 Reply)
Discussion started by: smarones
1 Replies

4. Shell Programming and Scripting

script prompts the user to enter four lines.

The script prompts the user to enter four lines. (1 Reply)
Discussion started by: polineni
1 Replies

5. Solaris

Console - root command prompt displayed twice after hitting enter

Dear All, I hope you can help me. I have a pair of E2900's I've inherited. Both running Solaris 9. Both have LOM> consoles. The problem I'm experiencing only occurs when connected to the /dev/console tty. Whenever I hit 'Enter' for a new line, I receive two new lines: - myhost# ... (11 Replies)
Discussion started by: aleith
11 Replies

6. Shell Programming and Scripting

How to enter commands to the command prompt in a program

Hey, So I'm trying to write a program in unix to automate a process for my astrophysics research. Basically I want the program to prompt the user for some information and store the entered string of text as a variable. I know how to do this. This is where I need help: Now lets say I have a... (4 Replies)
Discussion started by: freemoniez
4 Replies

7. Shell Programming and Scripting

enter password at prompt during a script?

I'm using rsync with the "-e ssh" option so of course it asks for a password using a prompt. Is there a way to tell a script to expect a prompt, wait for it, and give a password when it arrives? There is a way to give rsync a password as part of its options using a file, but it only works with... (2 Replies)
Discussion started by: davidstvz
2 Replies

8. Shell Programming and Scripting

Exit script if the user dosent enter any data within 5 seconds

Hello friends, Kindly help me in developing a script that asks user to enter a value and will wait for 5 seconds for the feedback. If there is no answer from the user the script will perform exit or it will continue doing something else Ex: If yu have a multi OS system i believe while... (3 Replies)
Discussion started by: frozensmilz
3 Replies

9. Shell Programming and Scripting

How to enter if-then condition on command prompt/line ?

Hi I have some trouble entering if-then condition in a single line on a command prompt in csh. Could someone show how does one do that ? eg: source .cshrc; cd $dir; pwd; test -d $backup_dir; if then mkdir -p ${backup_dir}; echo inside loop; fi; echo outside loop; mv -f... (3 Replies)
Discussion started by: mpc8250
3 Replies

10. Shell Programming and Scripting

User Prompt during batch script process

The script below performs an incremental database backup. When the increment backup is out of sequence, the process prompts the user: "Incremental backup out of sequece. Do you wish to continue? Y or N". This script is set to run as a scheduled process in background mode. When the script... (2 Replies)
Discussion started by: bond007jlv
2 Replies
Login or Register to Ask a Question