General :: Run Command Through Ssh But Also Run A If Check In Bash To See Ifa File Exist?
Aug 1, 2011
So I want to run command through ssh but also run a if check in bash to see ifa file exist. I know that to run ssh commands you do ssh user@server YOURCOMMANDbut if i need to run an if statements, how would this work??
View 4 Replies
ADVERTISEMENT
May 10, 2010
i tried to create a if else statements or either an else statement I get a message saying that the directory exists (mkdir: cannot create directory `./MAY2010': File exists I am running this in a crontab file and I dont want any output telling me that the directory exists. I just want to check if the directory doesnt exist, create one else do nothing (not even a message telling me that the directory exists).
[Code]....
View 8 Replies
View Related
May 9, 2011
I downloaded a program called tonespace http://www.mucoder.net/en/tonespace/ which I extracted and then tried to execute the executable file with ./tonespace. This gives me the following message:
bash: ./tonespace: No such file or directory
When I use the command: file ./tonespace I get this: tonespace: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
I dont get it. The file is clearly there, yet when trying to execute it bash doesn't seem to recognize it.
It has permissions rwxr-xr-x and is not owned by root. Am I overlooking something?
View 2 Replies
View Related
Nov 29, 2010
I create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:
Code:
#!/bin/bash
cat > ~/generateGridmix2data.sh << END
[code]...
View 6 Replies
View Related
May 8, 2010
I can do:mkdir messages and then: touch messages/hello.txt Is there a command that will do both - create the directory if it doesn't exist, and then the empty file? Something like: touch -p messages/hello.txt
View 1 Replies
View Related
Dec 10, 2010
I have been using linux for a bit of time but would still class myself as a noobie. I dont know excatly what I am looking for but I can best describe it in a sanario. I have started creating bash scripts which are looped indefinetly which checks afor files to process. my problem is, is there any way to check if the file is complete, as if the file is large and is being coppied from a different volume the file may still be copying or if the file is being uploaded by a user over samba/nfs, and if the file is still copying the process will most likely fail.
View 1 Replies
View Related
Nov 17, 2010
I'm building a RPM package. In my SPEC file, in the "%pre" and "%post" sections, I need to be sure that Postgresql-server is started.I tried to add a "PreReq: /var/run/postmaster*" but the * is not interpreted ! (filename changes, depending on the linux distribution)Is this way test that this file exist (or test if the result of "pidof -s/usr/bin/postmaster" is empty, for example
View 2 Replies
View Related
Jul 26, 2010
I've just installed java (jre-6u21-linux-i586.bin) on Red Hat 4.4 AS and issued this command to check the java version: java -versionand got :bash :java: command not found
View 4 Replies
View Related
Jan 20, 2011
As part of my script I need to compress a 50Gb file. but I need to check that the compressed is not corrupt if it is ok it will then send it over if not it will report an error.
cd /home/ops/Desktop/temp
tar czvf backup-"$(date +%d-%b-%y)".tgz /home/ops/Desktop/temp
I need some here to check the compress file then somelike if the file is
if
send the file
else
send an e-mail reporting a failure
View 4 Replies
View Related
Jun 9, 2011
I frequently use wget to download tarballs and zip files from the web, then either untar then or gunzip them. I do:
Is there a way for me to automatically pass the zip file to tar or unzip WHILE wget-ting?
In pseudocode: wget google.com/somfile.zip && unzip
View 3 Replies
View Related
Apr 28, 2010
I made a script that contains repetitious commands (snmpget and awk are the only ones at the moment. Running these commands from standard terminal work, but when run within a script, I get:
./reg_sm_count: line 10: snmpget: command not found
./reg_sm_count: line 10: awk: command not found
./reg_sm_count: line 10: snmpget: command not found
[code]...
View 2 Replies
View Related
May 29, 2011
Just trying to execute cd command in a .cshrc file (bash shell in SUSE Linux) it says."No such file or directory".Do you see any reasons for this
View 3 Replies
View Related
Sep 23, 2010
I have bash script for converting files. I have a problem. If file name is "corrupted" then mv command for that file will not work. For example file with "-" in front of the name.
Is there a way to check if in some folder (subfolder) all the files have correct file names or they don't?
If they are all correct -> OK proceed with execution of the script!
If they are not all correct -> NOT OK stop with execution of the script!
View 4 Replies
View Related
Oct 6, 2010
This script that I found online does the job it promises. it does convert the files to mp3 without an issue. What I need to include now is an if statement that says If $file.mp3 exists then delete $file.wav
Code:
#!/bin/sh
# name of this script: wav2mp3.sh
# wav to mp3
# Credit to the script creator (Nikesh Jauhari):
[Code]...
After that I'm stumped as to how to do the if statement
View 14 Replies
View Related
Feb 23, 2010
This should be simple but I can't seem to find what I am looking for.I want to search a text file for the existence of certain strings and execute a command if they exist, something along the lines of:
if <string> exists
command
or
if <any member of this list exists>
command
I know how to manually search a file with grep, cat, etc., but the "if this exists" part eludes me.
View 7 Replies
View Related
Oct 14, 2010
I want to be able to check the contents of a text file for a specific string and remove it from the file from the command prompt. I would basically be searching through a number of files and if a specific string is found I would like it removed automatically. pretty much a find and replace, were the replace is nothing. any one got any ideas on how you would do this. I already have the search part sorted just need to be able to remove the string I don't want from the multiple files.
View 4 Replies
View Related
Aug 6, 2011
I am trying to run Memtest86+ on my Linux computer. I use Grub 2, and Memtest86+'s core is located in /boot/memtest86plus/memtest.bin file.It seems to be pretty newbie error, but I can't find any documentation covering this problem.If I use linux16 instead of netbsd, computer just restarts without any error.
View 9 Replies
View Related
Jul 8, 2009
I use command "find" in my bash script: if the filename exist command find work quiet, and if the filename not exist I see the message "find: /tmp/filename: No such file or directory". My problem is following, i want to have in my script something like this:
find "/tmp/filename" -type f -delete | "if no_any_errors execute command1" , if file_not_found execute command2"
View 1 Replies
View Related
Nov 12, 2009
Can anybody tell what command can be used to check the checksum for a file or to match the checksum with the one provided by the download provider.
View 1 Replies
View Related
May 24, 2010
I'm running Slackware 13 - xfce4 and I got a new session in background. How could I see that session and use it? In backtrack I'm doing it via sessions in terminal but im Slackware 13 session command doesn't exist.
View 2 Replies
View Related
Aug 5, 2010
I need to find if, in a folder any directories exist, except a certain one named "mes croquis".What I am trying to say, is that the re already is a directory named "my croquis", which I have to ignore. IF any other directory appears, I have to archive them.I got everything so far, except the starting condition.In other terms , I am lookign for something like this:
IF anyDir EXIST AND name != "mes croquis"
do something
else
[code]....
View 2 Replies
View Related
Jan 27, 2011
I have file which consists of many files with their path,i need to check for the file exists in the given path,how to check?
View 12 Replies
View Related
Mar 9, 2011
I am trying to grep multiple numbers from file, grep does have the -f option for that.
Code: grep -f <`seq 500 520` /etc/passwd I know this could be done with
Code: for i in `seq 500 520`; do grep "$i" /etc/passwd; done But my question is fare more behind this example. It is possible to redirect one command output which will be treat as a content of file for another command ?
View 2 Replies
View Related
Jun 30, 2011
how to check two arguments whether it is a file and the other is a directory, check if files exist in directory and copy it if it is a newer version. Seriously i need idea to do tis, jst some simple sample wil do
View 3 Replies
View Related
Sep 27, 2010
I have a macro which I use with ROOT. In this macro I want to check if a part of string exist so I can ignore it inside a loop. So, inside a loop I want to have something like:
Code:
if (string == "pre_ti_data_bdt*" || string == "pre_ti_data_nn*")
continue;
but of course I cannot use * in this piece of code! How to do this trick in C++?
View 5 Replies
View Related
Apr 3, 2011
so I wrote a small script that pretty much just takes in two numbers and counts from the first to the second, e.g.
unknown-hacker|544> count.sh 1 3
1
2
3
My problem is I want to make it so that if you input invalid parameters, such as non-numerical characters, more than 2 numbers, etc., you'd get an error message
View 15 Replies
View Related
Mar 5, 2010
I know that $1 ... $n will set the argument to the values but what happened if I have many options in one scripts lets suppose.
I can run:
myscript -1stargument -2ndargument -3rdargument
or myscript -1stargument
or myscript -1stargument -3rdargument
In my scripts I have
if [ $1 = "-1stargument" -o $2 = "-2ndargument"] #for every instruction I need
fi
but is there any way to do:
if [ (any arguments or commands) = "(mydesired option ] ; then
(do this...)
fi
View 6 Replies
View Related
Aug 16, 2010
How can I check which version of bash I'm running
View 2 Replies
View Related
Nov 13, 2010
I have a bash script that messages the user periodically. Is there any way in the script to check if the screensaver is running, so the script doesn't spam messages while the user is away? The xscreensaver process is always running in the background, I've noticed.
View 5 Replies
View Related
Mar 20, 2010
i need to check if a cd is mounted or not using bash ... how is that possible?
View 8 Replies
View Related