Sponsored Content
Top Forums Shell Programming and Scripting determine if the script has been invoked manually or not? Post 302117409 by drl on Monday 14th of May 2007 08:08:28 AM
Old 05-14-2007
Hi.

I usually use the very old command tty. This script creates a little shell script that demonstrates tty. It calls the created script directly, and then runs it as an "at" job. The results of at jobs are mailed to you.
Code:
#!/bin/sh

# @(#) s1       Demonstrate tty.

echo " sh version: $BASH_VERSION"

cat >test-tty.sh <<EOF
#!/bin/sh

if tty -s
then
        echo " STDIN is connected to a terminal."
else
        echo " STDIN is NOT connected to a terminal."
fi
EOF

echo
chmod +x test-tty.sh
./test-tty.sh

echo
at -f ./test-tty.sh now

exit 0

Which, when run, produces:
Code:
% ./s1
 sh version: 2.05b.0(1)-release

 STDIN is connected to a terminal.

warning: commands will be executed using /bin/sh
job 14 at 2007-05-14 06:52

and here is the email message:
Code:
From drl@leap  Mon May 14 06:52:58 2007
Subject: Output from your job       14
To: drl@leap
Date: Mon, 14 May 2007 06:52:58 -0500 (CDT)
Status: R

 STDIN is NOT connected to a terminal

See man tty for details ... cheers, drl
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can run script Manually, but not through Cron?

Hi all, I have a main script (called OracleCleanup) that runs some sql queries. that runs off a wrapper script which contains the sources for the login information and and JOB_HOME (the script is below). When I schedule this job in the cron the log says that it cannot open my list file, which... (4 Replies)
Discussion started by: MadHatter
4 Replies

2. Shell Programming and Scripting

check in unix shell script so that no one is able to run the script manually

I want to create an automated script which is called by another maually executed script. The condition is that the no one should be able to manually execute the automated script. The automated script can be on the same machine or it can be on a remote machine. Can any one suggest a check in the... (1 Reply)
Discussion started by: adi_bang76
1 Replies

3. Shell Programming and Scripting

Passing the values to the secondary script when it invoked by primary script

Hi, When I invoke a script s1.sh it will call an another script s2.sh by itself. This script s2.sh will call some java files, so while running the script it asks for a file name to be processed. Which we can see in the screen. The file name to be processed is present in script s1.sh Now... (1 Reply)
Discussion started by: venu_eie
1 Replies

4. UNIX for Advanced & Expert Users

Passing the values to the secondary script when it invoked by primary script

Hi, When I invoke a script s1.sh it will call an another script s2.sh by itself. This script s2.sh will call some java files, so while running the script it asks for a file name to be processed. Which we can see in the screen. The file name to be processed is present in script s1.sh Now I... (2 Replies)
Discussion started by: venu_eie
2 Replies

5. UNIX for Advanced & Expert Users

why the script name not displayed and not sh invoked?

Say there is a shell script named test.sh. I intentionally omit the #! line in test.sh for testing perpose. I did the following : $ echo $0 -ksh ---> current shell $ echo $$ 12919 ---> PID of the current shell... (4 Replies)
Discussion started by: hongwei
4 Replies

6. Shell Programming and Scripting

CRON: Script not getting invoked

Hi, I have the following script - fixpart="/files/myScript # Transfer Script" echo "Specify the transfer frequency in minutes - " echo "every 1, 2, 3, or 5 minutes (default every 1 minute) " echo $nn "Frequency ? :" $cc read ans case $ans in 2) echo... (9 Replies)
Discussion started by: angshuman_ag
9 Replies

7. Shell Programming and Scripting

How to ensure a script can only be invoked from another?

Hi All, I have two scripts - ScriptA and ScriptB ScriptA has logic to invoke ScriptB : - with some parameter - or without any parameter ScriptB can also be invoked by the user from the command line. Is there anyway to ensure that when I execute ScriptB from the command line, it does... (3 Replies)
Discussion started by: chaitanya.gvc
3 Replies

8. Shell Programming and Scripting

Problem with script invoked from a keyboard shortcut

-EDIT- I have solved my problem below by using a different program. Instead of xsel I am using xclip which basically does the same thing and works fine from a script invoked by a global hotkey. -END EDIT- Hi, I've written a simple script to copy my email address into both the... (0 Replies)
Discussion started by: gencon
0 Replies

9. Shell Programming and Scripting

Oracle function invoked from shell script doubt

hi gurus, I have tried myself to invoke an oracle function. there are three different function available need to be called for differnt. can you tell me whether the below code is correct to call oracle function from shell script. Any help would be highly appreciated. cat location.sh ... (5 Replies)
Discussion started by: arun888
5 Replies

10. Shell Programming and Scripting

Script runs manually, but not from cron

Hi, I "borrowed" a script I found online, to start a SAP router application on a Solaris 11 (SPARC) server. The script runs fine when calling it manually, but when I schedule it to run from cron, it doesn't. I don't see any warning or failure messages anywhere, just nothing happens. ... (11 Replies)
Discussion started by: bredman
11 Replies
REMOTE-TTY(1)						      General Commands Manual						     REMOTE-TTY(1)

NAME
remote-tty - connect to a ttysrv serial console instance SYNOPSIS
remote-tty [-l LoginName] [-7] [-r] socket DESCRIPTION
remote-tty is the frontend for the remote-tty daemon. It is normally invoked using rconsole. It connects to the backend ttysrv process over a Unix socket and allows the user to view what's happening on the serial console and interact with it. OPTIONS
socket The full path to the Unix socket for the ttysrv instance to connect to. -l loginname Specify the login name to use. Defaults to the username if not specified. -r Set restricted mode; don't allow changing of logging status, suspending of remote-tty or setting of line options. -7 Set 7bit mode. SEE ALSO
rconsole(1), remote-tty(1), ttysrv(8). AUTHOR
rtty was written by Paul Vixie <vixie@isc.org>. This manual page was written by Jonathan McDowell <noodles@earth.li> for the Debian project (but may be used by others). May 23, 2006 REMOTE-TTY(1)
All times are GMT -4. The time now is 06:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy