Programming :: Variables With Spaces In Remote Ssh?

Nov 22, 2010

I'm writing something which takes user input (which may or may not contain spaces...) and then runs a command on a remote system via ssh. However the remote command does not work. I can't print the exact code so I'll just provide an equivelenat problem. This needs to work with filenames which do and do not contain spaces.

Code:
FILES=`ls`
echo "Specify a file"
echo "$FILES"
echo -n "File name: "
read $FILES
ssh root@127.0.0.1 "ls $FILES"

View 5 Replies


ADVERTISEMENT

Debian :: BASH Scripting - How To Use Variables With Filename Spaces

Jun 25, 2015

I am trying to create scripts to move files over from one directory to an ftp server and there is this one file with spaces that bash is see each word as being a file, here is the variable i am trying to use:

Code: Select allLOCL = '/mnt/cifs/"File name with spaces"/'
cd  $LOCL
ls -l

View 3 Replies View Related

General :: Shell - Rename A File From Something Without Spaces To Something Containing Spaces?

Jan 26, 2010

Is it possible, in Linux, to rename a file from something without spaces to something containing spaces? I know I can create directories and files with spaces by doing:

mkdir "new dir" and:

touch "new file.txt"

I want to rename files from:

imgp0882.jpg to something like:

20091231 1243 some topic.jpg

And how would it look in a shell script that uses parameters like:

for i in *.jpg do
rename "$i" "$somepath/$mydate $mytime $mytopic$extension"
?

I'm new to Linux (using PCLinuxOS 2009.2), coming from Windows, and I've written myself a little shell script to download files from my camera and then automatically rename them according to a date-and-topic pattern. As you can guess by now, I'm stuck on the bit about renaming. If you want to see my script, here's a copy. I'm not using jhead for this renaming because that only works with JPEG files but I want a single solution for any media format including videos.

View 2 Replies View Related

Programming :: Missing Separator Mean Tab Instead Of Spaces?

Jul 9, 2010

I am unable to write a simple Makefile. Though I know the concept am facing this error:
Makefile:2: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.
Should I give a tab or spaces not able to continue.

View 5 Replies View Related

Programming :: C++ Won't Detect Spaces In A String?

Oct 8, 2010

I have been trying to code a program in C++ that must check for the correct syntax in order to operate. It must find ", " within the string, but I don't know why the compiler won't recognizes spaces.

Code:
#include <iostream>
#include <stdio.h>
#include <string>

[Code]....

So the user must input "<name>, <interest>" with the ", " (comma and space) but even if you respect the syntax the compiler will skip to the else condition. I don't know why, but if I put any other condition like ",s" it will work, but not with spaces.

View 7 Replies View Related

Programming :: The 'a' String Doesn't Have Any Spaces In It?

Nov 27, 2010

I have a file of the type:

a = b

where a is any string and b is an integer The 'a' string doesn't have any spaces in it.

Everything was running fine till I was searching for 'a' and finding value 'b' by expression

Code:
string="$a"
egrep -i -m1 "^[[:space:]]$string[[:space:]]*=" | awk -F'=' 'gsub(/^[[:space:]]+/,"",$2)gsub(/[[:space:]]+$/,"",$2){print $2}'

I recently ran into a situation where in the string 'a' had symbols like $, & in it. Though I haven't checked it for & but $ is definitely breaking my code

Any way to egrep for string with $ ??

One way I though was to replace every occurence of $ with $ in my search expression but that would involve an extra processing each time

View 10 Replies View Related

Programming :: Python - How To Avoid Spaces

Oct 1, 2010

In the code below:

Code:

The output is:

Code:

Looks like the "," operator in the print inside the loop is adding a space for its own.

I want to print the sequence WITHOUT spaces. Something like this:

Code:

But I couldn't figure out how to do this.....

How to print a sequence, inside a loop, without that space ?

View 14 Replies View Related

Programming :: Pad End Of Each Line With Spaces To = 80 Chars?

Apr 14, 2011

I've searched the forums and the google looking for a means to do this and haven't found anything I can use. I have a large file that looks like this:

Code:

18000034161828M850
18000034172676M850
98 093095

[code]...

I need to add spaces at the end of each line to ensure that every line has 80 chars before the carriage return. I was thinking something like this, but it doesn't do the right thing:

Code:

cat filename | sed -e 's/$/(bunch of spaces)/' | cut -c1-80 > filename2

I'm on fedora, so I can use awk, sed, bash, ksh, etc.

View 14 Replies View Related

Programming :: Spaces Versus Tabs

Feb 24, 2010

Which do you prefer and why? Also, I remember someone telling me once that while using space indentation use either 4 spaces or 2 spaces. Don't use 3 spaces. Anyone know why they would say not to use 3 spaces?

View 14 Replies View Related

Programming :: Define All Variables In Tcl Programming In A File For Instance Var.cfg?

Apr 27, 2010

I can define all variables in tcl programming in a file for instance var.cfgand source the same file in my tcl script such assource var.cfgIs this possible in perl too?

View 3 Replies View Related

Programming :: Bash File Names With Spaces?

Jul 24, 2010

I have a laptop that I am in through SSH. The laptop does not have an Xwindow system so I am using the program fbi to open an image on my laptop screen from my SSH connection:

fbi -T 8 picture.jpg #this opens the image on the laptops tty8 terminal

I've found that making a for loop does not work with files that contain a space in the name. Something to due with a bug that they call a "feature" that stops the first variable at the first whitespace.

Using a "while" loop is not exactly what i require either seeing as I want to be able to view each image in the directory on screen and tag it accordingly, before it jumps off to the next image, and I'm not sure how to add a pause to a while loop.

How do I make a Bash script and loop Variables handle files like "files that contain spaces.jpg"

View 5 Replies View Related

Programming :: Grep Ignoring Spaces Or Tabs?

Jun 29, 2010

I writing a script to go through multiple reports. I want to grep daemon.debug @10.10.10.10 on all reports to make sure it is pointing to the right IP address. the problems is the space between debug and @10 are different on all the reports, some have one space some have two and some have tabs how do I ignore the tabs or spaces and grep daemon.debug @10.10.10.10

daemon.debug /var/log/ftp rotate size 20m files 4 compress
daemon.debug @10.10.10.10
authpriv.* /var/log/secure rotate size 20m files 4 compress
authpriv.* @10.10.10.10

View 6 Replies View Related

Programming :: Bash Script And Filename Spaces ?

Jan 15, 2010

I have over 50 files names with spaces in them.

I'm trying to use a for loop as such:

However, when I print the $filename in the script, the script prints out parts of the filename because of the spaces in the file name.

For example, say the file name was Star Quest.php

When the script executes one $filename would be Star and another Quest.php.

How could I account for this? Something like $'filename'

View 13 Replies View Related

Programming :: Using Sed To Remove Preceding And Trailing Spaces In CSV?

Sep 16, 2010

the preceding and trailing spaces around the commas in my CSV without destroying my address field. I'm new to regex and sed so this is probably easy but I just can't do it without destroying the Address section. I'm using vanilla Linux and sed 4.1.3I'm willing to use any regex or even awk if needed.

Example:
I need this
randall , dean, 11111 , 1309 Hillside Ave., Warsaw, VA , 23591

[code]....

View 11 Replies View Related

Programming :: Php Scripts Cant Locate Filenames With Spaces?

Apr 13, 2011

I have a fresh dedicated server that im currently configuring and needed a little help if I may ask.The problem is that i'm having a file naming issue. for example from the web I can access any file that does not have spaces of any type. ex/music/musicfile.mp3this works fine and my php script can locate itBut the problem is when I try to access a file that has spaces.ex/music/The Eagles - Hotel California.mp3my php script can't seem to locate any files like this with spaces but doesn't have a problem locating the files with no spaces.

I also took a look at the directory within shell. I did notice that files that have spaces are showing up in this formatt in shell.#/home/~username/public_html/music/The Eagles - Hotel California.mp3In shell , i'm assuming that unix/linux maybe adds a backslash before spaces. But when I FTP to this same directoy, the filename look normal and at windows standard. how could I correctly access these types of files within my php scrits? or would I need to have all uploaded files renamed so that spaces are replaced with underscores maybe?

View 4 Replies View Related

Programming :: Sed Insert Line With Leading Spaces?

Mar 3, 2011

I'm trying to insert a line using sed that has leading spaces before the text. Sed seems to be just dropping the spaces and only inserting the text. Any ideas what I'm missing?

Code:

NAM=rb134
sed -i.bak -e "$i
host ${NAM} {" /etc/crap

Instead of inserting a line with 8 leading spaces inserts it with "host" at the beginning of the line. I tried

Code:

NAM=rb134
sed -i.bak -e "$i
^ host ${NAM} {" /etc/crap

but it put the "^" at the begging of the line.

View 6 Replies View Related

Programming :: Reading And Writing White Spaces To A File?

Dec 2, 2010

I am trying to read a file character wise and trying to write the same character to another file. In this process, I unable to read and write white spaces successfully to the new file. The script reads the white spaces but while writing the white space is lost. The section of the code, is given below. Please advice how can i read and retain the white space while writing to a new file.

Code:

if [ -s f_test.txt ] && [ -f f_test.txt ]; then
echo "File Exists !!"
while read -n1 char; do

[code]....

View 2 Replies View Related

Programming :: Replace Spaces With Underscores In File Names?

Jan 11, 2011

I often get files with many spaces as part of their names. I would like to automatically replace these spaces with underscores, but otherwise not change the file name. Is there a way to do this task with just the bash shell?

View 4 Replies View Related

Programming :: BASH Script: Spaces Are Getting Converted To TAB Character?

Dec 23, 2010

I have a BASH shell script with embedded SQL script. The SQL script fetches the data from oracle server and the data contains more than 8 spaces in the value (eg, 28051630 A) and the data is written to flat file using the below syntax:

$ORACLE_HOME/bin/sqlplus -s ${CONNECT_STRING} >${out_file} <<!!
.. sql query..
!!

The problem is that whenever the data is written to ${out_file} spaces are getting converted to TAB character

eg, 10 spaces (in Oracle) converted to 1 TAB and 2 spaces 7 spaces (in Oracle) converted to 1 TAB and 1 space Also, from above example you can see the width of TAB char is not constant (8 in first example and 6 in second example) Is there any way that I can stop shell script to convert spaces into TAB character as I want the data as it is from Oracle DB (i.e. only spaces not TABs)

View 3 Replies View Related

Programming :: Handle Files With Spaces In Their Names In Bash?

Apr 1, 2011

*I'm using Ubuntu 10.10

My issue is I can't handle the files with spaces in their name, I've donde the below script to print each file found inside folder and subbfolders with "find".

I would like to "ls" to each file found with its complete path and with its basename too.

Code:
files=$(find . -type f)
for each in "$files"
do
ls -l "$each" # 1rst option I've tried to list with full path
ls -l "$(/bin/echo "$each")" # 2nd option I've tried to list with full path
ls -l "$(/bin/echo $(basename "$each"))" # 1nd option I've tried to list with it basename

[Code].....

How can I list "ls -l" in both cases (with full path and with basename) when there are files with spaces in their name?

View 6 Replies View Related

Programming :: If Statement Regex Match For White Spaces?

Apr 8, 2011

I want to match for this string:

Code:

Content-Transfer-Encoding:[:space:]base64
Content-Disposition:[:space:]attachment;[:space:]filename="%variable%"

Both lines are new lines, so they won't be inline. Other than that, they are all constants, I want this regex match to be an if statement rather than returning match string. so if the $content variable contains some string that matches:

Code:

if `sed "//p"` ;

View 4 Replies View Related

Programming :: Sed - Replace All Spaces At Beginning Of Line With The Number 1?

Jun 21, 2010

Does any one know what syntax i could use to allow me to replace all instances at the beginning of a line with ones.

Before :

Code:
----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
Logical device name : RAID1Mirror
RAID level : 1
Status of logical device : Optimal

After

Code:
----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
111Logical device name : RAID1Mirror
1111RAID level : 1
11111Status of logical device : Optimal

View 12 Replies View Related

Programming :: Unix Command To Remove White Spaces?

Sep 18, 2010

Im using this unix command(in a php file) to remove a certain string and then remove the whitespace left by that string. Unofrtunately in many cases, the files get completely erased. Is there a workaround?

Code

<?php
$dir = "./";
$rmcode = `find $dir -name "*.php"

[cod3e]....

View 14 Replies View Related

Programming :: Bash - How To Expand Path Variable That Contains Spaces And Wildcards

Feb 15, 2010

having bit of a trouble with path expansion of strings that contain some whitespace and wildcards First my script sources a configuration file that contains array assignments

Code:

...
BACKUP_TARGET_FILES[2]=/boot/config-* # no problems
BACKUP_TARGET_FILES[3]="/root/random dir with space/file*" # this is the problem
...

then later in the script I want to expand BACKUP_TARGET_FILES elements as below

Code:

IFS_DEFAULT="$IFS"
shopt -s nullglob
shopt -s dotglob
IFS=

[code]....

this code seems to work but I'm not quite satisfied with it. I'd like to get rid those IFS changes, but haven't found out a solution as of yet. Problem with default IFS seems to be that with it neither $pattern or "$pattern" work; it either interprets pattern as multiple words (because of spaces) and so expands to wrong paths or it ignores * because it's within quotes.

View 11 Replies View Related

Programming :: Auto_extract.sh Bash Script - Does Not Work With Any Paths That Contain Spaces

Jan 25, 2011

Have worked with Linux at home for some time and have wrote the below script.

This script is run when a .torrent file finishes downloading and extracts any .rar files into an extracted directory.

However there are 2 thing that i cannot for the life of me get working.

These are:

1. I need the script to check a txt file to see if the file has been extracted previously.

2. The script does not work with any paths that contain spaces.

Code:

View 11 Replies View Related

Programming :: Put Blank Spaces In Between List Of Numbers Generated In FORTRAN?

Aug 25, 2010

I have two sets of data. 1,2,3,4 and 6,7,8 and I have written a fortran code to put them in order as below:

program gap
implicit none
integer:: i, j
do i = 1,4
do j = 6, 8

[Code]...

I want a space once every row loop has finish.I am dont know how to write the data as shown above using the fortran code in this post.

View 2 Replies View Related

Programming :: Rename File Names : Replace Dots By Spaces, Keep The Extension?

Mar 28, 2011

I am trying to rename a lot of files but need to keep the extension :

the files are films names :

a.b.c.d.***.iso

the result should be replacing "." by spaces " "

this command :

for files in *.iso ; do mv "$files" `echo "$files" | tr '.' ' '`; done

put a space also before the extension iso ??

How can I rename files from

"a.b.c.d.iso" to "a b c d.iso"

View 5 Replies View Related

Programming :: Setting Variables In C-shell?

Jul 12, 2010

I'm running into a problem when I try to set a variable to an awk output in c-shell. Right now my command is Code: set STR_MSG_TYPE = `awk -F{ '/msg_type/ {print $2}' <filename> | tr -d }'/''*' ` I then run echo to see what the output is and it returns blank, however, when I run the same awk command from the command line, I get an actual output of "MT-715". Am I setting my variable incorrectly? I do something similar using the date command to set a STR_DATE variable earlier in the code and it works fine and I use the same syntax.

View 1 Replies View Related

Programming :: C With Gcc: Are All Variables Defined Like Pointers

Sep 13, 2010

i'm practicing in very basic c programs using the gcc compiler.I found that when i create two variables let's say

Code:

int a,b and Code: a=15;
b=3;
a=b;
b--;

then a equals 2.I thought that this isn't normal in C isn't it?I haven't had the time to read the gcc documentation yet...so i think it has something to do with my compiler's default settings.I use the

Code: gcc filename.c -o filename command to compile

Are all variables defined like pointers?

View 5 Replies View Related

Programming :: How To Check For Empty Variables In PHP

Apr 26, 2010

I want to check if a MySQL db query will return an empty result - I first do this:

$query="SELECT * from <whatever" ;
$result=mysql_query($query) ;
$row=mysql_fetch_row($result) ;

Now how do I check if $row is empty or not? Will $row="" do the trick?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved