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
# 8  
Old 03-15-2013
You missed -t option in your touch command to use [[CC]YY]MMDDhhmm[.ss] instead of current time.

If the option is not provided touch will simply create/touch 2 different files
Code:
touch -t "$start_date" /tmp/ref1
touch -t "$end_date"  /tmp/ref2

# 9  
Old 03-15-2013
Do use this set -x after #! line.

It will helpful for debugging Smilie
# 10  
Old 03-15-2013
You have a typo for your start_date variable.

Try adding the -t option to the touch command to allow entering the date in timestamp format.
# 11  
Old 03-15-2013
Script to prompt user to enter data

Hi

This is what I am getting:

Code:
#./transf
+ echo pls enter starting date format YYYYMMDDHHMM:
pls enter starting date format YYYYMMDDHHMM:
+ read star_date
201204250000
+ echo pls enter end date format YYYYMMDDHHMM:
pls enter end date format YYYYMMDDHHMM:
+ read end_date
201302282359
+ touch -t /tmp/ref1
date: bad conversion
+ touch -t 201302282359 /tmp/ref2
+ find /tmp/fr -type f ( -newer /tmp/ref1 -a ! -newer /tmp/ref2 )
+ 1> file_lst
+ 0< file_lst
+ ls -lrt /tmp/fr
total 236512
drwxr-xr-x  10 10000      10000         8192 Nov 15  2002 orca-0.27
-rw-r--r--   1 root       sys            314 Jan 21  2003 pr03
-rw-r--r--   1 203085     10545          314 Jan 21  2003 cfg2html_back.jpg
-rwxr-xr-x   1 203085     10545          794 Nov 13  2008 cfg2html

# 12  
Old 03-16-2013
so here is the problem that I noticed.

You are reading star_date and using start_date instead.
This User Gave Thanks to PikK45 For This Post:
# 13  
Old 03-16-2013
Script to prompt user to enter data

Hi

Thanks a lot, it does work if I do a
Code:
#more file_lst

:

Code:
-rw-r--r--   1 root       sys        1066269 Feb  1  2012 global_cpumem_nd0_jan12.out
-rw-r--r--   1 root       sys         536970 Feb  1  2012 nd0_cpu_jan12.out
-rw-r--r--   1 root       sys         291498 Feb  1  2012 nd0_disk_jan12.out
-rw-r--r--   1 root       sys        1066269 Feb  1  2012 global_cpumem_nd0_jan12.txt
-rw-r--r--   1 root       sys         536970 Feb  1  2012 nd0_cpu_jan12.txt
-rw-r--r--   1 root       sys         291498 Feb  1  2012 nd0_disk_jan12.txt
-rw-r--r--   1 root       sys        30243313 Apr 25  2012 xi-2009-latest.tar.gz
-rw-r--r--   1 root       sys        1714630 Apr 26  2012 nagios-3.3.1.tar.gz
-rwxrwxrwx   1 root       sys            208 Jun 21  2012 mov.ksh
drwxr-xr-x   4 root       sys           8192 Jun 21  2012 itc
-rwxrwxrwx   1 root       sys           2196 Aug 17  2012 netbandwidth.pl
-rw-r--r--   1 root       sys        10711040 Aug 17  2012 HP-UX_11.31_IA_PA_UtilProvider_A.01.08.07.00_HP-UX_B.11.31_IA_PA.depot
-rwxrwxrwx   1 root       sys            604 Sep  3  2012 test_d
-rwxrwxrwx   1 root       sys           1390 Sep  3  2012 daily_check
-rw-r--r--   1 root       sys        11048960 Feb 28 16:09 NRPE-2.12.depot
-rw-r--r--   1 root       sys              0 Mar 15 15:42 start_date
-rw-r--r--   1 root       sys              0 Mar 15 15:42 end_date
-rwxrwxrwx   1 root       sys            553 Mar 16 15:34 transf
-rw-r--r--   1 root       sys            715 Mar 16 15:35 file_lst
prep03[163]/tmp/fr #more file_lst
/tmp/fr/global_cpumem_nd0_jan12.out
/tmp/fr/nd0_cpu_jan12.out
/tmp/fr/nd0_disk_jan12.out
/tmp/fr/global_cpumem_nd0_jan12.txt
/tmp/fr/nd0_cpu_jan12.txt
/tmp/fr/nd0_disk_jan12.txt
/tmp/fr/test_d
/tmp/fr/itc/ICTEMSC32012060107100156508.cdr
/tmp/fr/itc/ICTEMSC62012060107000856497.cdr
/tmp/fr/itc/ICTEMSC52012060107100456510.cdr
/tmp/fr/itc/ICTEMSC62012053123250256110.cdr
/tmp/fr/itc/ICTEMSCH22012053123500456131.cdr
/tmp/fr/itc/ICTEMSC52012053123250056109.cdr
/tmp/fr/itc/mov.sh
/tmp/fr/itc/test
/tmp/fr/xi-2009-latest.tar.gz
/tmp/fr/nagios-3.3.1.tar.gz
/tmp/fr/mov.ksh
/tmp/fr/daily_check
/tmp/fr/netbandwidth.pl
/tmp/fr/NRPE-2.12.depot
/tmp/fr/HP-UX_11.31_IA_PA_UtilProvider_A.01.08.07.00_HP-UX_B.11.31_IA_PA.depot

but the last line of the script is:

Code:
ls -lrt $(< file_lst) /tmp/fr

# 14  
Old 03-18-2013
can you explain me what are you trying to do at the last line? Smilie
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