LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-26-2015, 04:38 PM   #1
mastersenpai
LQ Newbie
 
Registered: Jun 2015
Posts: 4

Rep: Reputation: Disabled
My perl script will not run under AT


I am creating a bash script that will automatically open and close a perl script with the AT command. This is on RHEL 6 cli only. The problem I am having is that the perl script can't open automatically, but can open manually. I had a log created whenever there is an attempt that AT executes a process in the queue. This is what I got "TERM not set at /root/testscript.pl line 154"

TERM is set to undef, but I asked a colleague of mine and he says that the main issue is that the perl script needs to run on its own terminal. This is what the bash script looks like.

Code:
echo "setsid sh -c 'bash -c /root/testscript.pl <> /dev/tty4 >&0 2>&1'" | at 14:00
echo "pkill -INT testscript" | at 15:10
echo "setsid sh -c 'bash -c /root/testscript.pl <> /dev/tty4 >&0 2>&1'" | at 15:20
echo "pkill -INT testscript" | at 16:30
echo "setsid sh -c 'bash -c /root/testscript.pl <> /dev/tty4 >&0 2>&1'" | at 16:40
echo "pkill -INT testscript" | at 17:50
I also tried
Code:
echo "bash -c /root/testscript.pl > /dev/tty4" | at 14:00
echo "pkill -INT testscript" | at 15:10
echo "bash -c /root/testscript.pl > /dev/tty4" | at 15:20
echo "pkill -INT testscript" | at 16:30
echo "bash -c /root/testscript.pl > /dev/tty4" | at 16:40
echo "pkill -INT testscript" | at 17:50
I even replaced bash -c with /usr/bin/perl. Still no luck. Any suggestions?

Last edited by mastersenpai; 06-26-2015 at 04:40 PM.
 
Old 06-27-2015, 03:48 AM   #2
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,493

Rep: Reputation: Disabled
Just a thought, but might it be better using cron for this(?).
 
Old 06-27-2015, 04:16 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by mastersenpai View Post
The problem I am having is that the perl script can't open automatically, but can open manually.
Please explain what the PERL script actually does, if you have tried debugging it, if you have actually set the TERM variable (as it actually asks for it) and if you really need to test things as root user? (And I doubt running it via cron would change anything.)
 
Old 06-27-2015, 11:30 AM   #4
mastersenpai
LQ Newbie
 
Registered: Jun 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fatmac View Post
Just a thought, but might it be better using cron for this(?).
I tried doing a cron job and it is the same result. Also, I don't want the script to run in a traditional pattern.
 
Old 06-27-2015, 11:33 AM   #5
mastersenpai
LQ Newbie
 
Registered: Jun 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by unSpawn View Post
Please explain what the PERL script actually does, if you have tried debugging it, if you have actually set the TERM variable (as it actually asks for it) and if you really need to test things as root user? (And I doubt running it via cron would change anything.)
It performs automated test calls to a FreeSWITCH server. I am doing everything in root. I tried googling what TERM variable I could change it to and even went to perldoc and couldn't find it.
 
Old 06-27-2015, 01:47 PM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
run complete scripts with at (not AT, by the way, that is something to do with modems):
Code:
$ cat dosomething.sh
#!/bin/sh

exec >>/tmp/debug.$$ 2>&1

set -xv

date

(actual commands)
$ echo './dosomething.sh' | at 14:00
On the other hand, if the problem exists in the 154th line of the perl-script, it cannot be solved via at
 
Old 06-29-2015, 09:55 AM   #7
mastersenpai
LQ Newbie
 
Registered: Jun 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
run complete scripts with at (not AT, by the way, that is something to do with modems):
Code:
$ cat dosomething.sh
#!/bin/sh

exec >>/tmp/debug.$$ 2>&1

set -xv

date

(actual commands)
$ echo './dosomething.sh' | at 14:00
On the other hand, if the problem exists in the 154th line of the perl-script, it cannot be solved via at
So then I take it that I can't be able to use the at command in the bash script and can only do that as an actual command? I'm still a little confused.

Last edited by mastersenpai; 06-29-2015 at 09:56 AM.
 
Old 06-29-2015, 10:15 AM   #8
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
I don't think I have suggested so... here is example I actually use:
Code:
#!/bin/sh

set -xv

TOMORROW=$(/usr/local/bin/gdate -d '+1 day' +'%Y%m%d')
WHEN="$TOMORROW"'0203'

at -t "$WHEN" <<DONE
/home/projects/hol/bin/e_somejob.stop.sh
/home/projects/hol/bin/e_somejob.start.sh
DONE

Last edited by NevemTeve; 06-29-2015 at 10:28 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Run Bash script from within Perl? arashi256 Programming 8 02-01-2012 07:26 AM
run shell script from perl kzcom Linux - Networking 4 09-04-2010 07:30 AM
I want to run script on the server from client machine in windows in a perl script vpradeep Linux - Newbie 2 09-01-2008 03:29 AM
MySQL Updates With Null When Perl Script Run From Shell Script ThisGuyIKnow Programming 6 08-12-2008 09:56 AM
how to run a shell script in the perl script sharad Linux - General 1 05-24-2006 03:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration