Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Symbolic link with command line parameters 1

Status
Not open for further replies.

RottPaws

Programmer
Mar 1, 2002
478
US
I've searched through this forum for information on ln with Linux, but I haven't been able to find an answer to my problem.

I've got a Perl script on a server running Redhat Linux 9.

The script takes a switch from the command line and runs a daily, weekly, or monthly version of a report depending on which switch is used.

I've got separate crontab directories for daily, weekly, and monthly scripts. Crontab uses the run-parts command to run everything in each of these directories at the scheduled time. These directories contain symbolic links to the scripts that are to be run.

This is my first time trying to schedule a script to run with a command line switch.

From the command line, I can execute the script by entering
./report.pl -d
or
./report.pl -m

I tried creating a link like:
ln -s /home/nps/reports/report.pl -w weekly_rpt
and
ln -s '/home/nps/reports/report.pl -w' weekly_rpt

But I can't get it to work.


_________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
If you are already using cron, why don't you just add the command to your crontab? As far as I know, there is no way to specify command line switches in a symbolic link, primarily because a symbolic link points to a file.

//Daniel
 
Rott,
You cannot create links to command lines. Run parts just runs whatever it finds in the directory. This would include scripts, sym links to programs, etc. As long as it is executable run-aprts will run it.

All you need to do is create a script in your daily directory like the following:
Code:
#!/bin/sh
# name - daily_rpt.sh

/home/nps/reports/report.pl -d daily_rpt
and a similar one in your weekly directory:
Code:
#!/bin/sh
# name - weekly_rpt.sh

/home/nps/reports/report.pl -w weekly_rpt
Make sure the script are executable and should be good.

Hope that helps.
 
We're moving stuff over from an old UNIX server to the Linux box and trying to clean things up as we move them.

This used to be 3 separate scripts. We could have added them to crontab, but the old crontab is a real mess and we were trying to avoid that on the new box.

The idea of creating a small script to execute the report script with the appropriate switch was just too obvious. We never even thought of it.

Thanks for the help!

_________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top