Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 30, 2013, 10:59 PM   #1
dancks
macrumors member
 
Join Date: Nov 2009
why does mkdir -p fail silently?

shell script:

Code:
#http://stackoverflow.com/questions/17204092/bash-script-trouble-interpretting-input/17204840?noredirect=1#17204840
#!/bin/bash
addr=$(ifconfig -a | ./check_ip)
relpath=$(./strip /users/me/Desktop/place_on_server/ $2)
if [[ $1 = "DIR" ]]
then
  shift
  #( IFS=/; echo ssh "root@$addr" mkdir -p "/var/www/media/$*"; )
  #( IFS=/; ssh "root@$addr" "mkdir -p /var/www/media/$*"; "chmod 755 /var/www/media/$*";)
  #( ssh "root@$addr" "mkdir -p /var/www/media/$relpath"; "chmod 755 /var/www/media/$relpath"; )
  ( ssh "root@$addr" "cd /var/www/media"; "mkdir -p $relpath/"; "chmod 755 $relpath/"; )
elif [[ $1 = "F" ]]
then
  shift
  last=$#
  file=${!last}
  #( IFS=/; echo rsync "$file" "root@$addr:/var/www/media/$*" )
  #( IFS=/; chmod 755 "$*"; rsync "$file" "root@$addr:/var/www/media/$*"; )
  ( IFS=/; chmod 755 "$*"; rsync "$file" "root@$addr:/var/www/media/$*"; )
else
  echo "Unknown command '$1'"
fi
I test that in terminal I get:

Code:
me$ ./upload DIR /users/me/Desktop/place_on_server/test-folder
./upload: line 11: mkdir -p test-folder/: No such file or directory
./upload: line 11: chmod 755 test-folder/: No such file or directory
EDIT: The title post is inaccurate. I did get an error-message. The thing is I have to use -p option because the folder in question may actually be embedded in another folder that doesn't exist on my server, but still. And I'm logged in as root.
dancks is offline   0 Reply With Quote
Old Jun 30, 2013, 11:21 PM   #2
dylanryan
macrumors member
 
Join Date: Aug 2011
Your quotes are wrong. As it stands, you will ssh onto the server and do a cd, then the ssh ends. then you try to execute "mkdir -p test_folder/" on the local machine. But the quotes make that one token, so it is literally looking for an executable named "mkdir -p test_folder/" (with embedded spaces), and isn't finding it.

Presumably you want the mkdir to be executed in the ssh, so make sure all the commands you want to execute on the server (including the semicolons) are enclosed in a single set of quotes. i.e.:

Code:
ssh "root@$addr" "cd /var/www/media; mkdir -p $relpath/; chmod 755 $relpath/"
The parens are also extraneous.
dylanryan is offline   1 Reply With Quote
Old Jul 1, 2013, 01:10 PM   #3
dancks
Thread Starter
macrumors member
 
Join Date: Nov 2009
thank you
dancks is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Apple Maps just one fail after another... security fail DanteMann iOS 6 6 Nov 18, 2014 02:32 AM
Applescript - check if connected to a specific network, then run (else fail silently) mixvio OS X 3 Feb 3, 2014 10:59 PM
Apple silently updates GM build petvas OS X Mavericks (10.9) 84 Oct 21, 2013 07:26 AM
Windows Sp3 Fail!+AppleMNT.sys Fail...Help! Liquigladiators Windows, Linux & Others on the Mac 6 Jun 9, 2013 06:37 PM
Terminal Problems- I couldn't do the command mkdir ProgrammerNewb OS X 4 Jan 9, 2013 06:28 PM

Forum Jump

All times are GMT -5. The time now is 07:39 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC