- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Exit from script to a .txt file..It does not work
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
Forums
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
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
09-19-2006 03:48 AM
09-19-2006 03:48 AM
I am developing a script to verify that a process has being executed and I'm sending the exit to a .txt file , the script for some motive not writing this one in the .txt file Someone will be able to help me with this? Please
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 03:53 AM
09-19-2006 03:53 AM
Re: Exit from script to a .txt file..It does not work
#!/usr/bin/sh
program_to_execute
echo $? >> result.txt
exit
PCS
- Tags:
- echo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 03:54 AM
09-19-2006 03:54 AM
Re: Exit from script to a .txt file..It does not work
It would be helpful to post your script. However, in general, all you should need is something like:
# ./myscript; echo $? > ./myscript.returnval
Make sure that you have permission to write into the directory that will hold the file containing the script's return value.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 03:55 AM
09-19-2006 03:55 AM
Re: Exit from script to a .txt file..It does not work
you can check the status of a script with $?
so:
/usr/sbin/fbackup -nAvf /dev/rmt/0m -s -g $GRAPH_DIR/graph >> $LOG_FILE 2>&1
STATUS=$?
if [ $STATUS != 0 ]
then
echo "error has occurred"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 05:45 AM
09-19-2006 05:45 AM
Re: Exit from script to a .txt file..It does not work
But
When I execute manually the script, the .txt file is update, the script is in a cron, when he script is executed from cron file, the .txt file is not update
- Tags:
- cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 05:58 AM
09-19-2006 05:58 AM
SolutionCron's environment is very sparse. That is, all you are provided for a PATH is:
PATH=/usr/bin:/usr/sbin:.
Hence, unless you explicitly declare the PATH and any other variables you need in your script, then that's all you get! Have a look at the 'crontab(1)' manpages for more information.
One other mis-used technique often seen is to source (read) your profile in the crontab before executing your script. This is a poor choice for a variety of reasons. I suggest that you declare all of the environmental variables you need either in your script or in a file that you source (read) in your script.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 06:07 AM
09-19-2006 06:07 AM
Re: Exit from script to a .txt file..It does not work
If you are comfortable with supplying your script, I'm sure we can point out the exact error.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 06:16 AM
09-19-2006 06:16 AM
Re: Exit from script to a .txt file..It does not work
HORA=$(date)
echo $HORA > file.txt
ps -ef | grep -v grep | grep svr > /dev/null 2> /dev/null
if [ "$?" -eq 0 ]
then
echo "================" >> file.txt
echo " Executing " >> file.txt
echo "===================" >> file.txt
else
echo "===============" >> file.txt
echo "NOT Executing " >> file.txt
echo "===============" >> file.txt
su - user -c "/home/user/start_service.sh"
fi
exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 06:20 AM
09-19-2006 06:20 AM
Re: Exit from script to a .txt file..It does not work
My script first line:
#!/bin/sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 06:45 AM
09-19-2006 06:45 AM
Re: Exit from script to a .txt file..It does not work
exec > $LOG_FILE 2>&1
That will write std out and std err to $LOG_FILE
Hope that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 08:21 AM
09-19-2006 08:21 AM
Re: Exit from script to a .txt file..It does not work
I solved the problem
A little detail with PATH
Bye and Thanks
; )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 08:22 AM
09-19-2006 08:22 AM
Re: Exit from script to a .txt file..It does not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 12:22 PM
09-19-2006 12:22 PM
Re: Exit from script to a .txt file..It does not work
There is no need to redirect the grep output to /dev/null if you use grep -q.
- Tags:
- grep