Sample Data
Script
The intention is to check and see if the directory exists, this runs on Red Hat 6. If the three jobs exist (which they should but that's besides the point) then it should put them in job.txt. If they do not exist then they should go in nojob.txt. If I run this line by line then it would end up correctly. If I run it like
Then it does just the opposite and all three go in /nojob.txt. Why is it behaving differently if I run it line by line compared to running the whole file? I'd like it to act the same either way.
What is that extension *.scr?
For scripts the extension usualy represents the shell its running, bash often been shortend to .sh as well.
It is a serious NO-GO to place scripts and data files in the system root.
Thats what /root, $HOME/.cache, /opt or /tmp is for, thought they're not necesarily better...
Note that you can place your scripts in $HOME/bin so you'll have them available whereever you are, as long you are the corresponding user.
Since i didnt see any error, i rewrote it.
In this script i've changed the used path/datadir to $HOME/data.
Hope this helps
I've used
short for script regardless of the shell. Non programming people run these things sometimes and I've tried to simplify it for them. I'm not actually writing to root, I removed path names I didn't want to post. I guess I'll leave it a mystery what it acts differently run line by line compared to the whole thing. I'll try what you provided.
scr is actualy a windows screensaver file extension.
Thats why i asked.
PS:
Some distros have .sh files associated with their default terminal, so a by double clicking (if it has execute flag) it will prompt to either open in terminal, editor or just execute it.
Naming it scr might prevent such a question, but idk.
hth
I didnt really change much, but i did assume a checkpath resolving error.
If run the below code today its creating all directory and getting output files,I f run same code tomorrow I am getting error.
can any one give suggestion to sortout this error.
OSError: no such file or directory : '062518'My code looks like this
import paramiko
import sys
import os ... (8 Replies)
I am having below script which needs to be executed based on start and end date
#!/bin/bash
array=('2016-09-27' '2016-10-27' '2016-11-27' '2016-12-27' '2017-01-27' '2017-02-27' '2017-03-27' '2017-04-27' '2017-05-27' '2017-06-27' '2017-07-27' '2017-08-27' '2017-09-27' )
for i in "${array}"
do... (9 Replies)
Dear All,
I want to run a shell script with out logging to putty but configuring it to a keyboard short cut it windows PC. Can this be done? I want this to rename a log in a specified folder in a system
Thanks (8 Replies)
OS : Red Hat Linux 6.4
Shell : Bash
We have a file called status.txt which will have only 1 line. The content will be the string "Processing" for most of the day.
# cat status.txt
Processing
#I want to write a shell script (notify.sh) which will be executing a grep every 10 minutes .
... (7 Replies)
If I run 'who -u' interactively or from a script invoked through bash in a tty on my Ubuntu 12LTS box I get an output like this:
testuser pts/0 Dec 9 02:32 . 2163 (host.xx.yy)
running the same through cron I get:
testuser pts/0 2012-12-09 02:32 00:05 2163... (2 Replies)
Okay, so I have a file containing line after line of three digit numbers. I need a script that does an action based on the last two numbers in this list.
So.... To get the last two numbers, I can have the script do
tail -2 filename.txt
But where I run into trouble is as follows. If... (6 Replies)
Hi All,
I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file.
Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
the following code runs, but it hangs somewhere, i don't know why,
#include<iostream>
#include<vector>
#include<cstdlib>
#include<ctime>
#include<list>
#include<pthread.h>
#include<cstring>
using namespace std;
pthread_mutex_t listlock = PTHREAD_MUTEX_INITIALIZER;... (3 Replies)
Hi Guys,
I am trying to convert a file which has a row based output to a column based output. My original file looks like this:
1
2
3
4
5
6
1
2
3
1
2
3 (8 Replies)
Hi,
In my application,I want to find out the OS name and based on OS I want to do some specific operations.So I write some code based on it in JAVA but I am able to get the OS name but Not able to use the method specific to OS.I write a simple code to check it and found that it is not going to... (1 Reply)