Execute the first line from last


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execute the first line from last
# 8  
Old 06-18-2010
Hi Scrutinizer,
I just tried your method to check what happens, and I am receiving this.

Code:
$ echo " 1  1 * * *  /path/to/abc.sh PB
 2  1 * * *  /path/to/abc.sh RA
 3  1 * * *  /path/to/abc.sh GS
 4  1 * * *  /path/to/abc.sh S
 5  1 * * *  /path/to/abc.sh SI
 6  1 * * *  /path/to/abc.sh DR
26  4 * * *  /path/to/abc.sh CT
26  6 * * *  /path/to/abc.sh DL
27  6 * * *  /path/to/abc.sh DE" | crontab
crontab: usage error: file name must be specified for replace
usage:  crontab [-u user] file
        crontab [-u user] [ -e | -l | -r ]
                (default operation is replace, per 1003.2)
        -e      (edit user's crontab)
        -l      (list user's crontab)
        -r      (delete user's crontab)
$

Is there something wrong which I am doing?
Code:
$ uname
CYGWIN_NT-5.1
$

# 9  
Old 06-18-2010
I think your particular crontab cannot read from stdin. Just redirect the echo to a temporary file and then use:
Code:
crontab tmpfile

This User Gave Thanks to Scrutinizer For This Post:
# 10  
Old 06-18-2010
ok.
Yes this worked.
Thank you.

I just looked at the man page for the possible options and found.
like usual way, in my crontab I need to provide "-" if the input is stdin.

Code:
SYNOPSIS
       crontab [-u user] file


       The  first  form  of  this command is used to install a new crontab from some named file or standard input if the
       pseudo-filename ``-'' is given.

So, this worked for me.
Code:
$ echo " 1  1 * * *  /path/to/abc.sh PB
 2  1 * * *  /path/to/abc.sh RA
 3  1 * * *  /path/to/abc.sh GS
 4  1 * * *  /path/to/abc.sh S
 5  1 * * *  /path/to/abc.sh SI
 6  1 * * *  /path/to/abc.sh DR
26  4 * * *  /path/to/abc.sh CT
26  6 * * *  /path/to/abc.sh DL
27  6 * * *  /path/to/abc.sh DE" | crontab -
$

Thanks a lot for the info.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

One Line Command how to use pipe statements to execute and comment on multiple possible outcomes

Hello Forum, I'm looking to expand the following command: INACTIVE_KERNELS=$(python -mplatform | grep -qi red && rpm -qa | grep '^kernel-' |grep -vE `uname -r` | paste -sd \; || echo "Not Red Hat Server") Currently this command will check if my server is RedHat server using the grep -qi... (6 Replies)
Discussion started by: greavette
6 Replies

2. Shell Programming and Scripting

Modifying bash script to take each line in a file and execute command

I need to modify a bash script to to take each line in a file and execute command. I currently have this: #!/bin/bash if ; then echo "Lipsa IP"; exit; fi i=1 ip=$1 while ; do if ; then rand=`head -$i pass_file | tail -1` user=`echo $rand | awk '{print $1}'` pass=`echo $rand | awk '{print $2}'`... (3 Replies)
Discussion started by: galford
3 Replies

3. Shell Programming and Scripting

sed working on command line but file unchanged when execute with Shell script

I have a simple task to replace unix line feed end of line characters with carriage returns. When I run the following “change file in place” sed instruction from the command line all the Line feeds are successfully replaced with Carriage returns. sed -i 's/$/\r/' lf_file.txt But that same... (1 Reply)
Discussion started by: hawkman2k
1 Replies

4. Shell Programming and Scripting

Read line by line and execute command

Hi ALL, I have a requirement like this. 1.GET ALL TABLE NAME (just table name) keep in file 2.Read line by line and get the count of table from tablename files. tablename detail has a sql statement "db2 select tabname from syscat.tables" (1 Reply)
Discussion started by: netdbaind
1 Replies

5. UNIX for Dummies Questions & Answers

Execute multiple comands on one single line

hi, I have a litle problem i wish to excute this comand : ./test.sh -e txt /home -l a so what it says is that "-e" shows me all the extenions that are ".txt" in "home" this works but then i wish that "-l" will show all files begining in this case with the letter "a" . Both comands work... (5 Replies)
Discussion started by: samirboss
5 Replies

6. Shell Programming and Scripting

execute by line based from file

Hi, i would like to know what command by not using FOR LOOP. For example file A #cat file A System1 System3 #cat file B echo "System1 is now up" echo "System2 is now up" echo "System3 is now up" echo "System4 is now up" echo "System5 is now up" echo "System6 is now up" Output:... (6 Replies)
Discussion started by: kenshinhimura
6 Replies

7. Shell Programming and Scripting

How to take input from the user from the command line and execute commands basedon that?

Hi, I am using solaris 10 and bash shell.Script execution follows below.Initially it will check whether a directory exists or not if does not exist it will create it.(This I have completed) Second step:I have four users say user1,user2,user3,user4.Script should prompt for the user id and... (11 Replies)
Discussion started by: muraliinfy04
11 Replies

8. Shell Programming and Scripting

How to read a file line by line and store it in a variable to execute a program ?

Hello, I am quite new in shell scripting and I would like to write a little scritp to run a program on some parameters files. all my parameters files are in the same directory, so pick them up with ls *.para >>dirafter that I have a dir file like that: param1.para param2.para etc... I... (2 Replies)
Discussion started by: shadok
2 Replies

9. Red Hat

How to execute linux script line by line

Hi All, I have created one startup.sh file. which contain below script. I want to start all service(meclipse, mycomputer,firefox..) with single shot. My problem is only one service can open at a time. If i close that particular service only second service will start. cd... (3 Replies)
Discussion started by: stsivaraj
3 Replies

10. Shell Programming and Scripting

How to execute the multiple line sql using shell script

Hi All, Please help me to write a shell script to execute the below sql query. select c.account_no,b.bill_no,a.pay_type,(b.total_due + b.recvd + b.adjusted + b.disputed + b.transferred) as amt_not_billed,d.cash_on_delivery, (select j.bill_no from billinfo_T y, bill_t j where... (1 Reply)
Discussion started by: girish.raos
1 Replies
Login or Register to Ask a Question