- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: csh scripts and at/cron command
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2015 08:38 AM
06-23-2015 08:38 AM
We are in the process of migrating from Solaris to HP-UX and have a large number of scripts written in csh that are called from at or cron.
Is there a way to get the at command to execute csh scripts as we don't have the time or resources to rewrite all of our scripts using the sh shell?
Thanks in advance.
Solved! Go to Solution.
- Tags:
- scummy C shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2015 08:41 AM
06-23-2015 08:41 AM
Re: csh scripts and at/cron command
at / cron doesn't care what the scripts are written in.
To make sure that all of your scripts run with the correct shell ALWAYS place the shell as the first line of the script, preceded by #!.
So for all of the scripts you are moving from Solaris to HP-UX, just make sure that this is the VERY FIRST line in the script:
#!/usr/bin/csh
That way your script will execute with the C-shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2015 09:01 AM
06-23-2015 09:01 AM
Re: csh scripts and at/cron command
Thanks for the reply.
The scripts are set up with "#!/usr/bin/csh" as the first line. One of the first things our script has is a "source" command to pull in common variables. The output from executing the at command is "sh[46]: source: not found." which tells me that it is not using the csh to execute. Here is one of the simpler scripts we are trying to run
#!/usr/bin/csh
#
# /*****************************************************************************
# * PROJECT : TransMon *
# * FUNCTION : *
# * DESCRIPTION : Schedule the script load_transmon_schedule.sh *
# * AUTHOR : Jaya Manoranjani Mekala *
# * DATE : May 12 2007 *
# * OUTPUT : None *
# *
echo "TransMon starting on Westlake Cps1."
source /opt/cps/transmon/scripts/load_control_transmon.var
set to = "apdev"
set toPager = "apdevPager"
set subject = "Load TRANSMON Schedule Start is on HOLD"
set body = "load_transmon_schedule_start.sh was placed on HOLD."
set execute = `echo "${transmon_sched_start}" | tr '[:lower:]' '[:upper:]'`
set pagerSubject = "Load TRANSMON Schedule Load Error"
set pagerBody = "Load TRANSMON Schedule Start is on HOLD as transmon_sched_start load status is: $execute"
echo Execut is $execute
echo $body
echo $load
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2015 09:06 PM
06-23-2015 09:06 PM
Solution> at / cron doesn't care what the scripts are written in.
I seldom use these things, so I know nothing, but that's what I'd've
said, and my quick test agreed:
dyi# uname -a
HP-UX dyi B.11.31 U ia64 4235313755 unlimited-user license
dyi# ls -l ct*
-rwxr-xr-x 1 root sys 49 Jun 23 12:43 ct.csh
-rw-r--r-- 1 root sys 17 Jun 23 12:42 ct2.cs
dyi# cat ct.csh
#!/usr/bin/csh
source ~root/ct2.cs
echo 'Done'
dyi# cat ct2.cs
echo ' ct2.cs'
dyi# date
Tue Jun 23 22:54:59 CDT 2015
dyi# echo '/root/ct.csh' | at 22:56
warning: commands will be executed using /usr/bin/sh
job 1435118160.a at Tue Jun 23 22:56:00 2015
And the mail I got said:
From root@dyi.antinode.info Tue Jun 23 22:56:01 CDT 2015
[...]
Subject: at
ct2.cs
Done
*************************************************
Cron: The previous message is the standard output
and standard error of one of your at commands.
The "man" page also talks about "/usr/bin/sh" doing all the work, but
if the script itself has a "#!" line, then /usr/bin/sh should run that
interpreter, which is what seems to happen here.
Does your script have "x" permission, and are you sure that you're
running the one which you think you're running? Does it work if you run
it interactively?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2015 07:51 AM
06-24-2015 07:51 AM
Re: csh scripts and at/cron command
There was a difference in how you called at and how we are calling at. We were using 'at -f script.sh now'. Trying to run our scripts using "echo 'script.sh' | at now" worked for us.
Thanks for the assistance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2015 12:47 AM - edited 06-26-2015 12:52 AM
06-26-2015 12:47 AM - edited 06-26-2015 12:52 AM
Re: csh scripts and at/cron command
>We were using "at -f script.sh now".
This tells at(1) to fiddle with the source file and prefix the Posix shell script with more Posix shell commands. Which won't work for the scummy C shell.
at(1) says: Enter commands from ...
And it does say by the Posix shell.
>Trying to run our scripts using "echo 'script.sh' | at now" worked for us.
This tells at(1) to execute the script with the single command "script.sh" from the Posix shell.
You may want to make this more efficient by:
echo 'exec script.sh' | at now
>at / cron doesn't care what the scripts are written in.
Quite the contrary, at(1) does but cron(1) doesn't.
(Unless for the latter you actually have a csh command in the crontab file. :-)