Tagged Questions
-2
votes
0answers
29 views
unexpected end of the file error [duplicate]
APP_FILE="/opt/tomcat/apache-tomcat-6.0.20/webapps/vold1/name_file.txt"
IPFILE="/opt/tomcat/apache-tomcat-6.0.20/webapps/vold1/ipaddres_file.txt"
...
-2
votes
2answers
23 views
how to take the file names from folder
i want to write a program for the below logic:
Take the names of files in a folder
For each file:
print file name
move the file to another new folder (with the name in dd_mm_yy format)
1
vote
3answers
66 views
How to get a response from any URL?
I have been asked to write a shell script To check if a URL is UP/Working or not for my Project.
I tried to find some hints over the internet, but whatever I got is about checking whether the URL ...
1
vote
1answer
29 views
Compare file size of multiple files in an array [closed]
Scenario:
Ftp site has 100s of files. Once a day, all the .gz files are copied to an AWS site then renamed. Only the date is kept in the file name.
Some of the files corrupted during copy.
A txt ...
0
votes
1answer
460 views
How to execute Netscaler commands through a remote machine via SSH connection
I have been trying to execute some NetScaler commands like "bind" & "unbind" through a Linux Box via an SSH Connection.
Now the Problem is, Manually we are able to enter & execute commands on ...
1
vote
3answers
58 views
List all the html tags in a file
I want to know if there is a way to list all the html tags in a file.
Lets say I have a file file.html
<html>
<head>
<title>Test</title>
</head>
<body>
This is a ...
2
votes
2answers
32 views
I seem to be “losing” this prompt. What is happening?
I ssh into an ubuntu 12.04 cloud server and start a web server like this (w/ bash):
$ nohup python tserver.py &
[2] 2122
$ nohup: ignoring input and appending output to `nohup.out'
After I run ...
10
votes
6answers
3k views
What are good online resources for learning shell scripting? [closed]
I am a beginner to shell scripting. I have not yet hardly coded a single program, but I am interested in learning it completely. Can anyone suggest some good online resources which will guide me?
4
votes
3answers
252 views
awk with if statements
I am trying to print from a file using awk, but my output is empty.
Here is my code so far
accountNum=$1
while read -r LINE || [[ -n $LINE ]] ; do
awk -F',' '{ if($1==accountNum) { print ...
2
votes
1answer
55 views
Renaming the files and move to other path
I need to rename the files given below and move to some other path
1234551abcde20140718023216001.txt.809047512.2014_07_07_13:47:44
000001abcde20140718023216001.txt.34568.001.2014_07_07_13:50:44
...
18
votes
4answers
7k views
How do I exit a script in a conditional statement?
I'm writing a bash script where I want to exit if the user is not root. The conditional works fine, but the script does not exit.
[[ `id -u` == 0 ]] || (echo "Must be root to run script"; exit)
...
1
vote
1answer
81 views
How to run java service as a non-root user on CentOs 6
I have a script that starts a Java application as a service on CentOS 6:
#!/bin/sh
# chkconfig: - 80 20
SERVICE_NAME=cn4server
PATH_TO_JAR=/usr/local/share/myserver/cn4server.jar
...
1
vote
3answers
174 views
How to read the file line by line and to print the previous line where the file contains a single token
For example my file is like:
59 6 18 2014 169 7 14 2 7671912 7849744 201 4
60 6 19 2014 170 5 49 2 7671912 7849744 201 5
61 6 20 2014 171 6 8 2 7671912 7849744 201 6
62 6 23 2014 174 5 3 2 7671912 ...
2
votes
1answer
136 views
What is the difference between filename=${1:-/etc/hosts} and filename=/etc/hosts? [duplicate]
What is the difference between filename=${1:-/etc/hosts} and filename=/etc/hosts?
For example:
filename=/etc/hosts
if [ -r "$filename" ] && [ -s "$filename" ]; then
md5sum $filename
...
0
votes
2answers
35 views
Simple server that triggers script and responds
I need to have a very simple server running that can:
Take rest call. It triggers a script when a call is made
The script checks if database is running or not.
If running then reply back to client ...
3
votes
3answers
2k views
Check whether files in a file list exist in a certain directory
The runtime arguments are as follows: $1 is the path to the file containing the list of files
$2 is the path to the directory containing the files
What I want to do is check that each file listed in ...
2
votes
1answer
53 views
How to simulate user interaction when running another script
I am new to shell scripting. When I want to run a bunch of Linux commands I do fine, but how do I give user input when another script is called and asks for input while it runs. Here is the situation ...
2
votes
4answers
153 views
How to initialize an array using awk and bash?
I am trying to store values of the first line of a text file into an array. Here is what I have so far:
arr_values=()
awk '
NR==1 {
for (i=0; i<=NF; i++)
...
1
vote
5answers
47 views
grep for text that may or may not be present
Lets say I have a file
batman;
robin;
superman;
password = "";
wonderwoman
green lantern
if I want to check if there is a password present, i.e there is something entered in the "" . here is an ...
1
vote
1answer
29 views
Assign diff -y column names
I have two files and a shell script.
File 1:
Batman
Superman
John Snow
Jack Sparrow
Rob Stark
File 2:
Batman
Ironman
Superman
Spiderman
John Snow
Arya Stark
Jack Sparrow
Rob Stark
The hound
...
5
votes
4answers
8k views
Processing bash variable with sed
Been banging my head off a wall on this
bash variable LATLNG contains a latitude & longitude value in brackets like so
(53.3096,-6.28396)
I want to parse these into a variable called LAT and ...
1
vote
6answers
84 views
Is there a way to find out the number of lines from a command output?
I am trying to compare command outputs between two servers. I want to find out the number of lines from the output of commands such as ls -l. Is there a way to do so? So far I have not found anything.
...
3
votes
3answers
62 views
Print a string including single quotes and other special characters
How can I write this with an AIX script correctly? My requirement is to write this command in test.txt:
clock=$(prtconf -s | awk '{print $4,$5}')
I tried this command:
print 'clock=$(prtconf -s | ...
0
votes
1answer
151 views
SQLPLUS withing shell script loops
Hello I am trying to run a loop and get the details of a project. I have these projects in my work space. How do I loop over the SQL code?
#!/bin/bash
workspace=$(sudo locate -r '/workspace$')
...
0
votes
1answer
56 views
Is there a way of copying only directories and not files in bash? [closed]
I want to copy only directories from a folder on a remote server to my server. Is that possible?
Here is the code I have so far but it copies files and folders:
scp -rq ...
0
votes
1answer
99 views
How do you keep the password hidden when invoked during the su command?
This is the first time it has happened to me where I am using the su command and it actually displays the password on the terminal and doesn't stay hidden. Here is my code snippet:
sshpass -p ...
0
votes
1answer
76 views
script to compare two string “foo” and “bar”
I'm going to create a script that should print "foo" or "bar" when a user's input is "foo" then print "bar" or when the user's input is "bar" then print "foo", otherwise show "invalid string". Here's ...
0
votes
0answers
28 views
convert many eps files in a single pdf or ps file using shell scriptI
I have SSt12.OLR.1.eps, SSt12.OLR.2.eps SSt12.OLR.3.eps SSt12.OLR.4.eps ......and covert these eps files into single pdf or post script file.
please suggest a shell script.
1
vote
2answers
123 views
Changing user to root when connected to a linux server and copying files
My script is coded in a way that doesn't allow you to connect to a server directly by root. This code basically copies files a server to my computer and it works but I don't have access to many files ...
3
votes
3answers
394 views
Case-insensitive substring search in a shell script [closed]
I'm trying to create a script which runs a command and compares the output of that command to a certain string to see if it contains that substring, ignoring the case of the string needed to be ...
2
votes
3answers
108 views
grep on a Java Method
Lets say I have a java class called DirectAction
some of the methods in the class have the word "action" or "Action"
What is the grep command to get the names of all the methods who have "Action" or ...
0
votes
1answer
74 views
Linux script for printing name [closed]
I have to Prompt the user to enter his/her name and Print all combinations of three letters from the name. How to write script for this?
1
vote
1answer
565 views
Press a html button via shell script?
i am currently trying to write a script to change some parameters on a webpage via a shell script. I can change the values in the textboxes without any problems, but i can't seem to figure out how i ...
1
vote
4answers
218 views
renaming multiple files increment order
I have the following files
SSt12.precip.374.sub.climatology.ctl
SSt12.precip.2874.sub.climatology.ctl
SSt12.precip.3764.sub.climatology.ctl
SSt12.precip.6774.sub.climatology.ctl
I want to rename ...
2
votes
2answers
78 views
AIX shell script compiler
I know it sounds strange, but is there a good tool that compiles a shell (.sh) script into a executable format? I want to protect the script in such a way it will not be modified by someone.
Thanks
4
votes
4answers
206 views
“Virtual” shell, ie. jailing an user inside a process after the (SSH) login
The title might not say much about the issue at hand so let me get straight to the point.
Let's assume I have a casual user who can log in to the system via SSH into a bash shell. I also have a PHP ...
1
vote
1answer
134 views
What does “if [ -e $name ]” mean? Where $name is a path to a directory
In the if [ -e $name ], what condition check is -e?
$name is a variable of a path to a directory.
0
votes
2answers
59 views
Different forms of executing a shell script
There are a few similar questions around that I've already seen, but I've come up with something different.
I'm reading this http://www.tldp.org/LDP/abs/html/invoking.html and I got confused when I ...
-2
votes
1answer
23 views
I want a script to do following simple task?
My input is :
a
a
l
a
c
g
b
c
... and so on rando alphabets.
A command or a awk statement which will give me:
a-1
1-2
l-1
a-3
c-1
g-1
b-1
c-2
basically counter for all alphabets and ...
3
votes
2answers
1k views
Shell script wait for background command
I am writing a script, but there is something I need that I can't find a way to do it...
I need to make a command in background "command1 &" and then somewhere in the script I need to wait for it ...
2
votes
7answers
409 views
Sort the files in the directory recursively based on last modified date
Sort the files in the directory recursively based on last modified date
I have modified a lot of files in my directory want to know what are those files by sorting them by the last modified date ...
1
vote
3answers
181 views
Delete files with same name at the end of the file
Delete files with same name at the end of the file
i have a lot of files in my folder and sub directories like
ajax_hostel_room_master.php.php class_hostel_registration.php.php
...
4
votes
3answers
565 views
Execute a command on user logon
In Linux desktop system, I want to execute a command when the user logs in.
After reading some other posts, I tried to insert the command in ~/.bashrc but unsuccessfully. Moreover, the system uses a ...
1
vote
1answer
89 views
how to check if mysql table is used or an application accesses the table in shell script?
A shell script is doing dump for a mysql table, but before dumping the table I want to check if this table is used by any other application. If so, I want to wait and enter in a loop until the ...
6
votes
1answer
194 views
When is it important to write portable scripts?
Most code I write is in PHP. I have recently started learning shell scripting. Most of the resources and tutorials that I've come across are specific to Bash. Some warn about bashisms and some don't. ...
1
vote
0answers
46 views
Logging into multiple SSH servers as root and create an user with same power as root does [closed]
I need a script from which I can log into multiple servers as root (but not all root passwords are same;there are 3-4 different root passwords) and make a superuser (user with same access as root) but ...
1
vote
1answer
63 views
How do I rename lots of files on a directory without changing their extensions? [duplicate]
I have a problem! I have a bunch of image files with extensions. Jpg and. Png. I wrote a script that renames the files, changing their names in a pattern followed by a number like this:
...
...
2
votes
3answers
116 views
creation of user add
I'm having more then 59 servers I need to create a script for user add.
purpose: if I'm creating a user in one server it will be reflected on all 59 servers. How can I accomplish this?
3
votes
3answers
415 views
if/then/else man page
I would like to know if there is any man page documenting the construction of the most basic script commands like if/then/else, while, for each, and all the relative switches, like -eq, -e, -ge, and ...
-2
votes
2answers
538 views
how to execute a python program in a shell script
I have a python program in that I wrote some python code (disk.py). I executed this program using the command python disk.py in a terminal, it worked.
Now I want to execute it using a shell script.